Repository navigation
Releases
Releases · davyddd/ddredis
v0.3.1
v0.3.0
⚠️ Breaking
ddredis.decoratorsis removed.GenericCachesuppressesRedisErrorthroughsafe_call(default_result=None, exceptions=(RedisError,), capture_exception=False)from ddutils 0.4, which handles coroutine functions, and keeps the decorator private. Code that importedsuppress_redis_errorsusesddutils.safe_decorators.safe_callwith the same arguments.- Requires
redis >= 6, < 9. The README documents the client's default retries (3 attempts with exponential backoff and jitter), which redis-py has since 6.0; 5.x retried once without a pause, so the documented productioncreate_funcdid not do what it said there. The CI matrix now tests redis 6, 7 and 8. - Requires
ddutils >= 0.4.0, < 0.5.0.
🔄 Changed
- The
GenericCachedocstring no longer claims msgspec compatibility: aStructhas neithermodel_validate_jsonnormodel_dump_json. Its example wires the client registry withprocess_loop_scopefrom ddutils 0.4.0.
📝 Docs
- GenericCache: the checks at class definition, the key format
:<snake_case_domain>:<key>,get_list/delete_by_filtersasSCAN MATCHover the whole keyspace, an entry that does not deserialize reads as a miss, the jitter isttl // 10and so zero under 10 seconds, the client may run with or withoutdecode_responses. - RedisLock: the full signature
RedisLock(client_factory, key, timeout=10.0, blocking=False, *, alias=None), the token-only design that borrows the client for every call,keystored as given,AlreadyAcquiredErroralso when a blocking wait runs out, not reentrant but reusable afterrelease(),extend()on an expired key raises redis-py'sLockNotOwnedErrorand either withoutacquire()raisesLockError. - RedisFeatureFlagStorage: the signature with
aliasandkey, the JSON record format, the strict parsing (an extra key is as malformed as a wrong value), a malformed record reads as the defaults and so disables its flag,get_mapkeeps the valid records. - The layout follows dd-lib-stub, with a Compatibility section.
Full Changelog: v0.2.0...v0.3.0
v0.2.0
🔄 Changed
RedisLocktakes the client from aConnectionManagerFactorylikeGenericCachedoes, with an optionalalias:RedisLock(client_factory, key, timeout=10.0, blocking=False, *, alias=None). The lock borrows the client inside every call and keeps only its token between them, so aKafkaConsumerMakercan be wired withlock_kwargs={'client_factory': redis_client_factory, 'timeout': 300}and no client has to be opened up front.release/extendwithout an acquired lock raise redis-py'sLockError, as before.GenericCache.client_factory,RedisFeatureFlagStorageandRedisLocktype the factory asConnectionManagerFactory[Any, Redis, Any], so a project'sConnectionManagerFactory[Alias, Redis, ConnectionManager[Redis]]passes the type checker.
⚠️ Breaking changes
RedisLock(redis_client, key, ...)→RedisLock(client_factory, key, ...).- Requires ddutils 0.3.3.
Full Changelog: v0.1.1...v0.2.0
v0.1.1
🚀 Added
feature_flags.RedisFeatureFlagStorage(client_factory, *, alias=None, key='feature_flags'): the Redis backend of ddutils feature flags. One hash, the field is the flag name, the value its JSON record (enabled,proportion,payload); the client comes from aConnectionManagerFactorylike the cache's;renameis one MULTI/EXEC pipeline. Redis errors raiseFeatureFlagStorageError, soFeatureFlagskeeps serving the last known values while Redis is down; a value that does not parse or validate is logged and read as the defaults.
Requires ddutils 0.3.2.
Full Changelog: v0.1.0...v0.1.1
v0.1.0
🔄 Changed
GenericCacheno longer holds a Redis client.client_factory, aConnectionManagerFactoryfrom ddutils called withalias, hands the client out for every call, the way a ddsql adapter runs a query insidefactory(alias=...). The factory owns the client's scope (aScopedRegistryper alias, one client per process and event loop, sinceredis.asyncioconnections bind to the loop they were opened in), its lazy creation and its close on shutdown throughclose().
⚠️ Breaking changes
GenericCache.redis_client→client_factory(+ optionalalias); close the clients withclient_factory.close()on shutdown.RedisLockstill takes the client of one block as before.- Requires ddutils 0.3.1.
Full Changelog: v0.0.3...v0.1.0
v0.0.3
🔄 Changed
- Requires
ddutils >= 0.3.0, < 0.4.0. ddutils 0.3.0 replaced theget_builtin_base_type/convert_to_builtinhelpers of 0.2.4 withget_base_value_type/convert_to_base_value; this library used neither, so nothing changes in its behaviour. The previous< 0.3.0pin kept the new ddutils out of every project depending on this library.
Full Changelog: v0.0.2...v0.0.3
v0.0.2
🚀 Added
- Python 3.11 support. The package now runs on 3.11–3.14, like the rest of the dd* libraries.
Full Changelog: v0.0.1...v0.0.2
v0.0.1
🚀 Added
GenericCache[DomainT]: an async JSON cache for domain objects in Redis. Subclass it with the domain type and aredis_client, getget,create,update,delete,get_list(key_prefix)anddelete_by_filters(key_prefix). Keys are prefixed with the snake_case domain name (:profile:42), the TTL defaults to 5 minutes and gets ±10% jitter so entries created together do not expire together. Any object withmodel_validate_json/model_dump_jsonworks (pydantic, msgspec, your own).RedisLock: a distributed lock as an async context manager over redis-py'sLock. A second holder getsAlreadyAcquiredErrorinstead of waiting (blocking=Trueto wait up totimeout).extend()resets the TTL totimeoutfrom now rather than adding to it, so a heartbeating holder that dies does not leave the lock held for the sum of its beats.release()tolerates a lock that already expired.suppress_redis_errors: a decorator for async functions that turns anyRedisErrorintoNone, so a Redis outage degrades a cache to "miss" instead of failing the request.GenericCachemethods use it.
Supports Python 3.12–3.14 and redis-py 5–8.
Full Changelog: https://github.com/davyddd/ddredis/commits/v0.0.1