Full featured Valkey and Redis cache backend for Django
Project description
django-cachex
Cache extensions for django, including full featured Valkey and Redis cache backend for Django and a built-in admin interface.
Installation
pip install django-cachex[valkey]
# or
pip install django-cachex[redis]
Quick Start
CACHES = {
"default": {
"BACKEND": "django_cachex.cache.ValkeyCache", # or RedisCache
"LOCATION": "valkey://127.0.0.1:6379/1", # or redis://...
}
}
Features
- Full-featured cache backends for Valkey and Redis with async support, extended data structures, distributed locking, Lua scripting, and more
- Built-in admin interface for browsing, searching, and managing cache keys directly from Django admin
- Drop-in replacement for Django's built-in Redis backend
Cache Backends
- Unified Valkey and Redis support - Single package for both backends
- Async support - Async versions of all extended methods
- Mixing sync & async support - Async cache still works in sync code
- Extended data structures - Hashes, lists, sets, sorted sets
- TTL and pattern operations -
ttl(),expire(),keys(),delete_pattern() - Lua script support - Register and execute Lua scripts with automatic key prefixing
- Distributed locking -
cache.lock()for cross-process synchronization - Sentinel and Cluster - High availability and horizontal scaling
- Pluggable serializers - Pickle, JSON, MsgPack with fallback support
- Pluggable compressors - Zlib, Gzip, LZ4, LZMA, Zstandard with fallback support
Cache Admin
Add django_cachex.admin to your INSTALLED_APPS to enable the cache admin interface:
INSTALLED_APPS = [
# ...
"django_cachex.admin",
]
Browse all configured caches, search and filter keys by type, and manage values directly:
Features:
- Browse all configured cache backends (Valkey, Redis, LocMemCache, DatabaseCache, and more)
- Search keys with wildcard patterns (
user:*,*:session) - Filter by key type (string, list, set, hash, zset, stream)
- View and edit values with type-specific operations
- Inspect and modify TTL
- View server info and memory statistics
- Flush caches
For django-unfold users, use django_cachex.unfold instead for a themed interface.
Documentation
Full documentation at oliverhaas.github.io/django-cachex
Requirements
- Python 3.12+
- Django 5.2+
- valkey-py 6.0+ or redis-py 6.0+
Acknowledgments
This project was started from django-redis and Django's official Redis cache backend. Some utility code for serializers and compressors is derived from django-redis, licensed under BSD-3-Clause. The admin functionality was inspired by django-redisboard. All of the above I used in production, noticed some flaws over the years, and for one reason or another a new package ended up the best way for progress for me here.
The Unfold theme integration optionally uses django-unfold.
I also want to mention django-valkey and dj-cache-panel, which I never really used, but are newer and interesting efforts of similar goals as this package has.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_cachex-0.3.0.tar.gz.
File metadata
- Download URL: django_cachex-0.3.0.tar.gz
- Upload date:
- Size: 97.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a583d130248c7188df3f936e525a4a426a1c540307eaa9629f4704c6ba59c519
|
|
| MD5 |
021dd9907e54280c1a565e5daff3b211
|
|
| BLAKE2b-256 |
791f6fb661f4c575dc2db1100c0f5b0838228223eae8570089ddf9e5b2c6ca2f
|
Provenance
The following attestation bundles were made for django_cachex-0.3.0.tar.gz:
Publisher:
publish.yml on oliverhaas/django-cachex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_cachex-0.3.0.tar.gz -
Subject digest:
a583d130248c7188df3f936e525a4a426a1c540307eaa9629f4704c6ba59c519 - Sigstore transparency entry: 953234548
- Sigstore integration time:
-
Permalink:
oliverhaas/django-cachex@642e5338a0da5f82003d0c4b203c6b330a157282 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/oliverhaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@642e5338a0da5f82003d0c4b203c6b330a157282 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file django_cachex-0.3.0-py3-none-any.whl.
File metadata
- Download URL: django_cachex-0.3.0-py3-none-any.whl
- Upload date:
- Size: 132.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce839136f6fed341f3307fca65d8071471d9a472cef34be5cab80b7787cc555e
|
|
| MD5 |
a8862515db438f68d0832980ee7865b4
|
|
| BLAKE2b-256 |
39e3732534e218b8b0e729fab013294cde7d45438f6dbd2a26225937a892ef64
|
Provenance
The following attestation bundles were made for django_cachex-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on oliverhaas/django-cachex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_cachex-0.3.0-py3-none-any.whl -
Subject digest:
ce839136f6fed341f3307fca65d8071471d9a472cef34be5cab80b7787cc555e - Sigstore transparency entry: 953234549
- Sigstore integration time:
-
Permalink:
oliverhaas/django-cachex@642e5338a0da5f82003d0c4b203c6b330a157282 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/oliverhaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@642e5338a0da5f82003d0c4b203c6b330a157282 -
Trigger Event:
workflow_dispatch
-
Statement type: