Skip to main content

Full featured Valkey and Redis cache backend for Django

Project description

django-cachex

PyPI version Python versions CI

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:

Cache list Key list Key detail

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 inspired by 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 aboved 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_cachex-0.2.0.tar.gz (108.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_cachex-0.2.0-py3-none-any.whl (143.5 kB view details)

Uploaded Python 3

File details

Details for the file django_cachex-0.2.0.tar.gz.

File metadata

  • Download URL: django_cachex-0.2.0.tar.gz
  • Upload date:
  • Size: 108.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_cachex-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7ed0c6f85d450ba736dfd4775aea9bc1bcae9e481c5ec84432f90b5428a00f47
MD5 777267160fd592fcd703d789320ff25a
BLAKE2b-256 add480a3c9dcd0912d709f144b78bc5a0e23e49895e7f4c179c40e0b419f06d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_cachex-0.2.0.tar.gz:

Publisher: publish.yml on oliverhaas/django-cachex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_cachex-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: django_cachex-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 143.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_cachex-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3364ae6119104068b260c9976d795c2d40d96dbcfd5feec42134343eba3b9025
MD5 07de934d2da543c3d38861bd1d45965e
BLAKE2b-256 d597610b9a4ed8d679c9b2538120b5b0e1292a465e8a97666ac2610b0ee4fefb

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_cachex-0.2.0-py3-none-any.whl:

Publisher: publish.yml on oliverhaas/django-cachex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page