import time from typing import Any, Optional class ManualCache: """ Very simple in-memory TTL cache for the Manual MVP. Stores GET lists and details. Clears fully on any mutation. """ def __init__(self, ttl_seconds: int = 300): self.ttl = ttl_seconds self._store = {} def get(self, key: str) -> Optional[Any]: item = self._store.get(key) if item is None: return None if time.time() > item["expires"]: del self._store[key] return None return item["value"] def set(self, key: str, value: Any): self._store[key] = { "value": value, "expires": time.time() + self.ttl } def clear(self): self._store.clear() # Global singleton instance for the app manual_cache = ManualCache(ttl_seconds=300) # 5 min cache