mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-03 19:57:35 +00:00
Merge 5a0d71452e
into d266c59c2a
This commit is contained in:
commit
80c04e26d5
2 changed files with 7 additions and 2 deletions
|
@ -31,10 +31,12 @@ class RedisKVStoreConfig(CommonConfig):
|
|||
type: Literal["redis"] = KVStoreType.redis.value
|
||||
host: str = "localhost"
|
||||
port: int = 6379
|
||||
db: int = 0
|
||||
ttl: int = None
|
||||
|
||||
@property
|
||||
def url(self) -> str:
|
||||
return f"redis://{self.host}:{self.port}"
|
||||
return f"redis://{self.host}:{self.port}/{self.db}"
|
||||
|
||||
@classmethod
|
||||
def pip_packages(cls) -> list[str]:
|
||||
|
|
|
@ -26,7 +26,10 @@ class RedisKVStoreImpl(KVStore):
|
|||
|
||||
async def set(self, key: str, value: str, expiration: datetime | None = None) -> None:
|
||||
key = self._namespaced_key(key)
|
||||
await self.redis.set(key, value)
|
||||
if self.config.ttl:
|
||||
await self.redis.set(key, value, ex=self.config.ttl)
|
||||
else:
|
||||
await self.redis.set(key, value)
|
||||
if expiration:
|
||||
await self.redis.expireat(key, expiration)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue