autogen_ext.cache_store.redis#

class RedisStore(redis_instance: Redis)[source]#

Bases: CacheStore[T]

A typed CacheStore implementation that uses redis as the underlying storage. See ChatCompletionCache for an example of usage.

Parameters:

cache_instance – An instance of redis.Redis. The user is responsible for managing the Redis instance’s lifetime.

get(key: str, default: T | None = None) T | None[source]#

Retrieve an item from the store.

Parameters:
  • key – The key identifying the item in the store.

  • default (optional) – The default value to return if the key is not found. Defaults to None.

Returns:

The value associated with the key if found, else the default value.

set(key: str, value: T) None[source]#

Set an item in the store.

Parameters:
  • key – The key under which the item is to be stored.

  • value – The value to be stored in the store.