Releases: dperezcabrera/pico-caching
Releases · dperezcabrera/pico-caching
Release list
pico-caching v0.1.1
pico-caching v0.1.1
Config prefix consistency release. No functional changes.
Changed
- The configuration prefix is now
caching(wascache), matching the ecosystem rule that the prefix equals the package name suffix (pico-actuator->actuator:,pico-resilience->resilience:,pico-caching->caching:). A uniform rule is guessable-correct; with zero-config defaults, a wrongly guessed prefix is silently ignored rather than an error, so the exception was a misconfiguration trap.
# before (0.1.0) # after (0.1.1)
cache: caching:
default_ttl_seconds: 60 default_ttl_seconds: 60Compatibility
- Breaking only for
application.yamlfiles written against 0.1.0 (published minutes earlier): rename the block. - Python 3.11+ · pico-ioc >= 2.2.0
Install
pip install --upgrade pico-caching==0.1.1pico-caching v0.1.0
pico-caching v0.1.0
First public release. Declarative method caching (@cacheable) over pico-ioc interception with pluggable backends, auto-discovered by pico-boot. Zero-config. No prior versions; no migration required.
Highlights
@cacheable(ttl_seconds, key=...)on any@componentmethod — sync or async; the awaited result is cached, never the coroutine.- Built-in backend: thread-safe in-memory LRU with per-entry TTL (
time.monotonic), bounded bycache.max_entries. - Bring your own backend: implement the 4-method
CacheBackendprotocol as a@componentand it replaces the built-in automatically — no registry, no config. - Repr-based default keys (explicit and debuggable);
key=callablefor custom keys. - Exceptions are never cached;
cache.enabled: falsebypasses everything.
Deliberately not in v0.1.0
@cache_evict and a Redis backend — planned once real usage asks for them. Invalidate today by injecting the backend (delete/clear).
Example
from pico_ioc import component
from pico_caching import cacheable
@component
class UserRepo:
@cacheable(ttl_seconds=60)
async def find(self, user_id: int): ...Compatibility
- Python 3.11+ · pico-ioc >= 2.2.0
Tests
- 5 tests. Pinned behaviors: hit/miss per argument set, TTL expiry, async caches the awaited result (single execution across awaits),
enabled: falsebypasses, and LRU eviction order in the built-in backend.
Install
pip install pico-caching