Changelog
v0.2.1
Bug Fixes
- Fix stampede protection recomputing the value once per waiting request — waiters now reuse the value cached by the lock holder
- Fix
timedeltaexpiration being silently ignored byRedisBackend, which left values uncached - Fix
MemcachedBackendrejecting keys with whitespace or longer than 250 bytes, which prevented caching any function called with keyword arguments; such keys are now hashed - Fix expiration timestamps being truncated to whole seconds in DynamoDB, MongoDB and Firestore backends, which could expire entries up to a second early
- Fix MongoDB TTL index never removing expired documents — entries now include an
expires_at_datefield used by the TTL index - Fix
MongoDBBackend.set()withoutexpirekeeping the previous expiration of an existing key - Fix
lifespan_handlerfailing on startup withTypeError: 'State' object does not support item assignment - Fix
lifespan_handlernot awaiting async backendclose(), leaving Redis, Memcached and DynamoDB connections open - Pin
apscheduler<4, as APScheduler 4 removes the scheduler API used by the in-memory, Postgres and Firestore backends
Behavior Changes
- Cache backend errors inside
@cachedare now logged and the wrapped function runs normally, instead of the error propagating. Errors raised by the wrapped function itself still propagate.
New Features
RedisBackend.try_acquire_lock()/atry_acquire_lock(): single non-blocking lock attempt that raises on Redis errors. Used by@cachedto skip lock waiting when Redis is unreachable.
v0.2.0
New Features
- Distributed cache stampede protection via Redis locking
- Python 3.14 support
Bug Fixes
- Fix infinite loop in
InMemoryBackendcleanup scheduler thread (#3) - Fix Firestore cleanup using wrong client type when batch exceeds 500 docs
- Fix DynamoDB async resource leak in
_get_async_table()— properly handles__aenter__/__aexit__ - Fix cache decorator not caching
Nonereturn values — uses sentinel value instead ofNonecheck - Fix
AttributeErrorafterInMemoryBackend.close()— cache is now cleared instead of destroyed - Fix async pool/table race condition in Postgres and DynamoDB backends using double-checked locking
- Add warning logs to silent exception handlers in Redis, Memcached, and DynamoDB backends
Testing
- Add concurrency tests for async initialization in Postgres and DynamoDB backends
- Add Redis lock unit tests (acquire, release, exclusivity, auto-expiry)
- Add Python 3.14 to tox test matrix