Migration Guide¶
From Django's Built-in Cache Backend¶
# Before (Django's Redis backend)
"BACKEND": "django.core.cache.backends.redis.RedisCache"
# After (Valkey)
"BACKEND": "django_cachex.cache.ValkeyCache"
# Or (Redis)
"BACKEND": "django_cachex.cache.RedisCache"
All existing Django cache options work unchanged.
From django-valkey¶
# Before
"BACKEND": "django_valkey.cache.ValkeyCache"
"OPTIONS": {"CLIENT_CLASS": "django_valkey.client.DefaultClient"}
# After
"BACKEND": "django_cachex.cache.ValkeyCache"
Key changes:
| django-valkey | django-cachex |
|---|---|
CLIENT_CLASS |
Removed - use specific backend class |
SERIALIZER |
serializer (lowercase) |
COMPRESSOR |
compressor (lowercase) |
CONNECTION_POOL_CLASS |
pool_class |
get_valkey_connection() |
cache.get_client() |
Import paths: django_valkey.* → django_cachex.*
For Sentinel: Use django_cachex.cache.RedisSentinelCache (or ValkeySentinelCache) instead of CLIENT_CLASS.
From django-redis¶
# Before
"BACKEND": "django_redis.cache.RedisCache"
"OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient"}
# After
"BACKEND": "django_cachex.cache.RedisCache"
Key changes:
| django-redis | django-cachex |
|---|---|
CLIENT_CLASS |
Removed - use specific backend class |
SERIALIZER |
serializer (lowercase) |
COMPRESSOR |
compressor (lowercase) |
CONNECTION_POOL_CLASS |
pool_class |
get_redis_connection() |
cache.get_client() |
Import paths: django_redis.* → django_cachex.*
For Sentinel: Use django_cachex.cache.RedisSentinelCache instead of CLIENT_CLASS.
New Features¶
After migrating, you gain:
- Valkey and Redis in one package.
- Multi-serializer/compressor fallback for safe migrations.
- Extended data structures (hashes, lists, sets, sorted sets) directly on the cache object.
- TTL operations:
ttl(),pttl(),expire(),persist(). - Pattern operations:
keys(),iter_keys(),delete_pattern(). - Distributed locking via
cache.lock(). - Pipelines via
cache.pipeline().