mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-04 03:16:03 -05:00
enh: redis dict for internal models state
Co-Authored-By: cw.a <57549718+acwoo97@users.noreply.github.com>
This commit is contained in:
@@ -86,6 +86,15 @@ class RedisDict:
|
||||
def items(self):
|
||||
return [(k, json.loads(v)) for k, v in self.redis.hgetall(self.name).items()]
|
||||
|
||||
def set(self, mapping: dict):
|
||||
pipe = self.redis.pipeline()
|
||||
|
||||
pipe.delete(self.name)
|
||||
if mapping:
|
||||
pipe.hset(self.name, mapping={k: json.dumps(v) for k, v in mapping.items()})
|
||||
|
||||
pipe.execute()
|
||||
|
||||
def get(self, key, default=None):
|
||||
try:
|
||||
return self[key]
|
||||
|
||||
Reference in New Issue
Block a user