redis_openai_agents.RedisConnectionPool#

class RedisConnectionPool(redis_url='redis://localhost:6379', max_connections=20, decode_responses=True)[source]#

Shared Redis connection pool for all components.

Provides connection pooling to reduce connection overhead and improve resource management across components.

Example

>>> pool = RedisConnectionPool(
...     redis_url="redis://localhost:6379",
...     max_connections=50,
... )
>>> client = pool.get_sync_client()
>>> async_client = pool.get_async_client()
Parameters:
  • redis_url (str) – Redis connection URL

  • max_connections (int) – Maximum pool size (default: 20)

  • decode_responses (bool) – Whether to decode responses (default: True)

Initialize the connection pool.

Parameters:
  • redis_url (str) – Redis connection URL

  • max_connections (int) – Maximum pool size

  • decode_responses (bool) – Whether to decode responses

__init__(redis_url='redis://localhost:6379', max_connections=20, decode_responses=True)[source]#

Initialize the connection pool.

Parameters:
  • redis_url (str) – Redis connection URL

  • max_connections (int) – Maximum pool size

  • decode_responses (bool) – Whether to decode responses

Return type:

None

Methods

__init__([redis_url, max_connections, ...])

Initialize the connection pool.

aclose()

Close all connections including the async client.

close()

Close sync connections in the pool.

get_async_client()

Get an async Redis client from the pool.

get_sync_client()

Get a sync Redis client from the pool.

Attributes

max_connections

Maximum pool size.

redis_url

Redis connection URL.

sync_pool

Underlying sync connection pool.