memory / scratchpad.py — Scratchpad

In-memory LRU + optional SQLite persistence with per-entry TTL (default 24 h).

Storage

API

MethodPurpose
__init__(max_entries=50, persist_path=None, ttl=86400)LRU + TTL config.
set(key, value) -> strStore; LRU evict if over capacity.
get(key) -> Optional[Any]Retrieve; TTL check; refresh accessed_at (sliding-window TTL).
list_all() / count() / delete(key) / clear()Standard helpers.

Eviction model

threading.RLock guards in-memory dict + SQLite.