import time from typing import Any, Dict, Tuple class TTLCache: def __init__(self, ttl_seconds: int = 600): self.ttl = ttl_seconds self._store: Dict[str, Tuple[float, Any]] = {} def get(self, key: str): item = self._store.get(key) if not item: return None expires_at, value = item if time.time() > expires_at: self._store.pop(key, None) return None return value def set(self, key: str, value: Any): self._store[key] = (time.time() + self.ttl, value)