MCPcopy Create free account
hub / github.com/DSGWJQ/Feagent / __init__

Method __init__

src/infrastructure/memory/in_memory_cache.py:59–80  ·  view source on GitHub ↗

初始化缓存 Args: ttl_seconds: TTL 时长(秒),默认 900(15分钟) max_workflows: 最大缓存 workflow 数量,默认 1000 max_messages_per_workflow: 每个 workflow 最多缓存消息数,默认 50

(
        self,
        ttl_seconds: int = 900,  # 15 分钟
        max_workflows: int = 1000,
        max_messages_per_workflow: int = 50,
    )

Source from the content-addressed store, hash-verified

57 """
58
59 def __init__(
60 self,
61 ttl_seconds: int = 900, # 15 分钟
62 max_workflows: int = 1000,
63 max_messages_per_workflow: int = 50,
64 ):
65 """
66 初始化缓存
67
68 Args:
69 ttl_seconds: TTL 时长(秒),默认 900(15分钟)
70 max_workflows: 最大缓存 workflow 数量,默认 1000
71 max_messages_per_workflow: 每个 workflow 最多缓存消息数,默认 50
72 """
73 self._ttl = timedelta(seconds=ttl_seconds)
74 self._max_workflows = max_workflows
75 self._max_messages = max_messages_per_workflow
76 self._cache: OrderedDict[str, CacheEntry] = OrderedDict()
77
78 # 监控指标
79 self._hits = 0
80 self._misses = 0
81
82 def get(self, workflow_id: str) -> list[ChatMessage] | None:
83 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected