AsyncRedisStore#
Asynchronous key-value store with optional vector search, backed by Redis.
- class AsyncRedisStore(redis_url=None, *, redis_client=None, index=None, connection_args=None, ttl=None, cluster_mode=None, store_prefix='store', vector_prefix='store_vectors')[source]#
Bases:
BaseRedisStore[Redis,AsyncSearchIndex],AsyncBatchedBaseStoreAsync Redis store with optional vector search.
Supports standard Redis URLs (redis://), SSL (rediss://), and Sentinel URLs (redis+sentinel://host:26379/service_name/db).
Initialize store with Redis connection and optional index config.
- Parameters:
redis_url (Optional[str])
redis_client (Optional[AsyncRedis])
index (Optional[IndexConfig])
connection_args (Optional[dict[str, Any]])
ttl (Optional[TTLConfig])
cluster_mode (bool | None)
store_prefix (str)
vector_prefix (str)
- classmethod from_conn_string(conn_string, *, index=None, ttl=None, store_prefix='store', vector_prefix='store_vectors')[source]#
Create store from Redis connection string.
- Parameters:
conn_string (str)
index (IndexConfig | None)
ttl (TTLConfig | None)
store_prefix (str)
vector_prefix (str)
- Return type:
AsyncIterator[AsyncRedisStore]
- async abatch(ops)[source]#
Execute batch of operations asynchronously.
- Parameters:
ops (Iterable[GetOp | SearchOp | PutOp | ListNamespacesOp])
- Return type:
list[Item | list[Item] | list[SearchItem] | list[tuple[str, …]] | None]
- batch(ops)[source]#
Execute batch of operations synchronously.
- Parameters:
ops (Iterable[GetOp | SearchOp | PutOp | ListNamespacesOp]) – Operations to execute in batch
self (AsyncRedisStore)
- Returns:
Results from batch execution
- Raises:
asyncio.InvalidStateError – If called from the main event loop
- Return type:
list[Item | list[Item] | list[SearchItem] | list[tuple[str, …]] | None]
- configure_client(redis_url=None, redis_client=None, connection_args=None)[source]#
Configure the Redis client.
Supports standard Redis URLs (redis://), SSL (rediss://), and Sentinel URLs (redis+sentinel://host:26379/service_name/db).
- Parameters:
redis_url (str | None)
redis_client (Redis | None)
connection_args (dict[str, Any] | None)
- Return type:
None
- async start_ttl_sweeper(_sweep_interval_minutes=None)[source]#
Start TTL sweeper.
This is a no-op with Redis native TTL, but kept for API compatibility. Redis automatically removes expired keys.
- Parameters:
_sweep_interval_minutes (int | None) – Ignored parameter, kept for API compatibility
- Return type:
None
- async stop_ttl_sweeper(_timeout=None)[source]#
Stop TTL sweeper.
This is a no-op with Redis native TTL, but kept for API compatibility.
- Parameters:
_timeout (float | None) – Ignored parameter, kept for API compatibility
- Returns:
Always True as there’s no sweeper to stop
- Return type:
bool
- async sweep_ttl()[source]#
Clean up any remaining expired items.
This is not needed with Redis native TTL, but kept for API compatibility. Redis automatically removes expired keys.
- Returns:
Always returns 0 as Redis handles expiration automatically
- Return type:
int
- cluster_mode: bool | None = None#
- store_index: AsyncSearchIndex#
- supports_ttl: bool = True#
- ttl_config: TTLConfig | None = None#
- vector_index: AsyncSearchIndex#