1.16.0 — Redis Cache Adapter
Adds a Redis-backed cache for distributed deployments:
- New adapter:
rbacx.core.redis_cache.RedisCacheimplementingAbstractCache - Designed for multi-process / multi-host setups where in-memory cache is not shared
- Available via extra:
rbacx[cache-redis]
Usage:
import redis
from rbacx import Guard
from rbacx.core.redis_cache import RedisCache
guard = Guard(
policy,
cache=RedisCache(redis.Redis(), prefix="rbacx:", default_ttl=300),
)Key properties:
-
JSON serialization (no
pickle) -
TTL precedence: explicit
ttl→default_ttl→ no expiry -
clear()usesSCANwith prefix glob (neverFLUSHDB) -
Redis errors are swallowed and logged at DEBUG level:
- treated as cache miss
- never impact authorization decisions
-
Compatible with:
redis.Redisredis.cluster.RedisCluster- any compatible client interface
No breaking changes
Upgrade
pip install -U "rbacx[cache-redis]"