autogen_ext.cache_store.redis#

class RedisStore(redis_instance: Redis)[source]#

基类: CacheStore[T], Component[RedisStoreConfig]

一个类型化的 CacheStore 实现,它使用 redis 作为底层存储。有关用法示例,请参见ChatCompletionCache

参数:

cache_instanceredis.Redis的一个实例。用户负责管理 Redis 实例的生命周期。

classmethod _from_config(config: RedisStoreConfig) Self[source]#

从配置对象创建一个组件的新实例。

参数:

config (T) – 配置对象。

返回:

Self – 组件的新实例。

_to_config() RedisStoreConfig[source]#

转储创建与此实例的配置匹配的组件新实例所需的配置。

返回:

T – 组件的配置。

component_config_schema#

别名 RedisStoreConfig

component_provider_override: ClassVar[str | None] = 'autogen_ext.cache_store.redis.RedisStore'#

覆盖组件的提供程序字符串。这应该用于防止内部模块名称成为模块名称的一部分。

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

从存储中检索一个项目。

参数:
  • key – 存储中标识项目的键。

  • default (optional) – 如果未找到键,则返回的默认值。默认为 None。

返回:

如果在找到,则与键关联的值,否则为默认值。

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

在存储中设置一个项目。

参数:
  • key – 要存储项目的键。

  • value – 要存储在存储中的值。

pydantic model RedisStoreConfig[source]#

基类: BaseModel

RedisStore 的配置

显示 JSON 模式
{
   "title": "RedisStoreConfig",
   "description": "Configuration for RedisStore",
   "type": "object",
   "properties": {
      "host": {
         "default": "localhost",
         "title": "Host",
         "type": "string"
      },
      "port": {
         "default": 6379,
         "title": "Port",
         "type": "integer"
      },
      "db": {
         "default": 0,
         "title": "Db",
         "type": "integer"
      },
      "username": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Username"
      },
      "password": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Password"
      },
      "ssl": {
         "default": false,
         "title": "Ssl",
         "type": "boolean"
      },
      "socket_timeout": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Socket Timeout"
      }
   }
}

字段:
field db: int = 0#
field host: str = 'localhost'#
字段 password: str | None = None#
字段 port: int = 6379#
字段 socket_timeout: float | None = None#
字段 ssl: bool = False#
字段 username: str | None = None#