MCPcopy Index your code
hub / github.com/AgentOps-AI/agentops / SimpleCache

Class SimpleCache

app/api/agentops/common/cache.py:49–75  ·  view source on GitHub ↗

In-memory cache for local development.

Source from the content-addressed store, hash-verified

47 return 0
48
49 class SimpleCache(BaseDevCache):
50 """In-memory cache for local development."""
51
52 def __init__(self):
53 self.store = defaultdict(lambda: None)
54 self.expiry = {}
55
56 def get(self, key: str) -> str | None:
57 if key in self.expiry and time.time() > self.expiry[key]:
58 del self.store[key]
59 del self.expiry[key]
60 return None
61 return self.store[key]
62
63 def setex(self, key: str, expiry: int, value: str) -> None:
64 self.store[key] = value
65 self.expiry[key] = time.time() + expiry
66
67 def expire(self, key: str, expiry: int) -> None:
68 if key in self.store:
69 self.expiry[key] = time.time() + expiry
70
71 def delete(self, key: str) -> None:
72 if key in self.store:
73 del self.store[key]
74 if key in self.expiry:
75 del self.expiry[key]
76
77 class SQLiteCache(BaseDevCache):
78 """SQLite-backed cache for local development."""

Callers 1

cache.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…