| Name | Type | Description |
|---|---|---|
redis_url | str | Default: 'redis://localhost:6379'The URL of the Redis instance to connect to. |
name | Optional[str] | Default: _DEFAULT_CACHE_NAMEName of the cache index, as passed to
|
prefix | Optional[str] | Default: _DEFAULT_CACHE_PREFIX |
redis_client | Optional[Redis] | Default: None |
backfill | bool | Default: False |
Upgrade a semantic cache index created by an earlier version.
This method adds the llm_string tag field to the existing index and keeps
its keys. By default the entries themselves are not touched, so the cache
starts cold: entries cached before the upgrade are no longer returned, but
still expire via TTL and are removed by clear().
With backfill=True, each of those entries is also moved to the key the
current version would write it to, which keeps the cache warm.
Example:
RedisSemanticCache.migrate_index(
redis_url="redis://localhost:6379",
name="my_semantic_cache",
backfill=True,
)
Note:
entry_id, and its original expiration deadline.Prefix for the keys, as passed to
RedisSemanticCache.
An existing Redis client instance.
If provided, redis_url is ignored.
Whether to also migrate the existing entries.
This scans the whole cache.