mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-29 19:06:23 +02:00
feat: +cache
This commit is contained in:
parent
b5ea3c692f
commit
4d9cfe6f43
1 changed files with 3 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ from typing import Dict, List
|
|||
import pydantic
|
||||
|
||||
from metagpt import Message
|
||||
from metagpt.logs import logger
|
||||
from metagpt.utils.redis import Redis
|
||||
|
||||
|
||||
|
|
@ -86,6 +87,7 @@ class BrainMemory(pydantic.BaseModel):
|
|||
if not redis.is_valid() or not redis_key:
|
||||
return BrainMemory()
|
||||
v = await redis.get(key=redis_key)
|
||||
logger.info(f"REDIS GET {redis_key} {v}")
|
||||
if v:
|
||||
data = json.loads(v)
|
||||
bm = BrainMemory(**data)
|
||||
|
|
@ -99,6 +101,7 @@ class BrainMemory(pydantic.BaseModel):
|
|||
return False
|
||||
v = self.json()
|
||||
await redis.set(key=redis_key, data=v, timeout_sec=timeout_sec)
|
||||
logger.info(f"REDIS SET {redis_key} {v}")
|
||||
self.is_dirty = False
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue