|
|
@@ -139,11 +139,16 @@ class LocalMemory(MemoryBackend):
|
|
|
|
|
|
|
|
|
class SQLiteMemory(MemoryBackend):
|
|
|
- """SQLite memory backend. Persistent on disk."""
|
|
|
+ """SQLite memory backend. Persistent on disk.
|
|
|
|
|
|
- def __init__(self, size: int = 20, ttl: int = 3600, db_path: str = ":memory:"):
|
|
|
+ S14: namespace isolates memory by tenant/agent.
|
|
|
+ """
|
|
|
+
|
|
|
+ def __init__(self, size: int = 20, ttl: int = 3600, db_path: str = ":memory:",
|
|
|
+ namespace: str = ""):
|
|
|
self.size = size
|
|
|
self.ttl = ttl
|
|
|
+ self.namespace = namespace
|
|
|
self.conn = sqlite3.connect(db_path)
|
|
|
self.conn.execute("""
|
|
|
CREATE TABLE IF NOT EXISTS memory (
|
|
|
@@ -202,11 +207,16 @@ class SQLiteMemory(MemoryBackend):
|
|
|
|
|
|
|
|
|
class RedisMemory(MemoryBackend):
|
|
|
- """Redis memory backend. Cross-process, cross-machine."""
|
|
|
+ """Redis memory backend. Cross-process, cross-machine.
|
|
|
|
|
|
- def __init__(self, size: int = 20, ttl: int = 3600, redis_url: str = ""):
|
|
|
+ S14: namespace isolates memory by tenant/agent.
|
|
|
+ """
|
|
|
+
|
|
|
+ def __init__(self, size: int = 20, ttl: int = 3600, redis_url: str = "",
|
|
|
+ namespace: str = ""):
|
|
|
self.size = size
|
|
|
self.ttl = ttl
|
|
|
+ self.namespace = namespace
|
|
|
try:
|
|
|
import redis
|
|
|
self.r = redis.from_url(redis_url or "redis://localhost:6379/0")
|