API¶
pico_caching.decorators ¶
@cacheable marker: stores the policy and attaches the interceptor.
cacheable(_func=None, *, ttl_seconds=None, key=None) ¶
Cache the method's return value. Sync or async; async methods cache the awaited result, never the coroutine. key(*args, **kwargs) overrides the default repr-based key; ttl_seconds overrides cache.default_ttl_seconds.
Source code in src/pico_caching/decorators.py
pico_caching.interceptor ¶
Cache interceptor: get-or-compute through the selected backend.
CacheInterceptor ¶
Uses the first user-provided CacheBackend; falls back to the built-in in-memory LRU.
Source code in src/pico_caching/interceptor.py
pico_caching.backend ¶
Cache backend protocol and the built-in in-memory LRU backend.
CacheBackend ¶
Bases: Protocol
Implement as a @component to replace the in-memory backend.
Source code in src/pico_caching/backend.py
InMemoryCacheBackend ¶
Thread-safe LRU with per-entry TTL (time.monotonic based).