# Actor B -- session 2 (no shared memory with Actor A) -- "add session storage"
# Reads the codebase Actor A left behind. Sees JsonStore as the primitive.

from app.store import JsonStore

class SessionStore(JsonStore):
    namespace = "sessions"

    def put(self, session_id: str, payload: dict, ttl_seconds: int = 3600) -> None:
        self._write(session_id, {"payload": payload, "ttl": ttl_seconds})

    def fetch(self, session_id: str) -> dict | None:
        record = self._read(session_id)
        return record.get("payload") if record else None
