django-valkey
a valkey backend for django
What it is and what it does
django-valkey is a BSD-licensed cache and session backend that integrates Valkey (a free, well-maintained key-value store) into Django. It is a fork of django-redis and reuses its mature design while targeting Valkey instead of Redis. The package provides native support for Valkey's connection strings, async operations, pluggable clients and serializers, primary/secondary replication, Unix sockets, and infinite timeouts. It has been used in production for caching and session storage and includes a comprehensive test suite.
You configure it in Django settings by specifying a Valkey location URL and then use Django's standard cache API to interact with Valkey transparently. The package is highly configurable—you can emulate memcached exception behavior, choose compression algorithms (lz4, zstd, brotli), and select alternative serializers (msgpack, msgspec) via optional extras. It requires Python 3.10+, Django 4.2.20 or later (but not 5.0 or 5.1), and Valkey server 7.2.6+.
Use it for:
- Replace Django's default in-memory cache with a persistent, distributed Valkey backend for multi-process or multi-server deployments.
- Store Django session data in Valkey instead of the database to reduce database load and improve session performance.
- Use async cache operations in Django async views and middleware for non-blocking cache access.
- Configure primary/secondary Valkey nodes for cache redundancy and read scaling.
- Integrate custom serializers or compression algorithms to optimize cache storage and network bandwidth.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Valkey cache and session backend for Django, allowing you to use Valkey as a drop-in replacement for Django's default caching and session storage.
Yes, if you are running Django 4.2.20+ or 5.2+ on Python 3.10+ and have a Valkey server available. The package is actively maintained, has low install friction, carries no known vulnerabilities, and offers a production-ready alternative to in-memory or database-backed caching. Avoid it only if you are locked into Django 5.0 or 5.1, or if you require Redis specifically rather than Valkey.
Install
django-valkey on PyPI
pip
pip install django-valkeyuv
uv add django-valkeypoetry
poetry add django-valkeyInstalling django-valkey
Before you install
Low friction installation with a pure-Python wheel. Actively maintained as of August 2026 with recent commits and 81 repository stars. Requires Django 4.2.20+ and Python 3.10+; note that Django 5.0 and 5.1 are explicitly unsupported due to end-of-life status.
License in practice
BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; you must retain copyright notices and the license text in distributions.
Quickstart
pip install django-valkey
# In Django settings.py:
CACHES = {
'default': {
'BACKEND': 'django_valkey.cache.ValkeyCache',
'LOCATION': 'valkey://localhost/1',
}
}
# Then use Django's cache API:
from django.core.cache import cache
cache.set('key', 'value')
Requires a running Valkey server (7.2.6+) accessible at the configured location; also requires Python 3.10+ and Django 4.2.20+.
Verify before relying
- Whether async cache operations are fully production-ready or still experimental.
- Performance characteristics compared to the original django-redis project it forked from.
- Stability of pluggable serializer and parser interfaces across minor versions.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — django, typing-extensions, valkey |
| Maintenance | actively maintained — 100 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 77,734/month — #14,502 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_valkey-0.4.1-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
django-redisProvides a Redis cache and session backend for…
permissive · top 5,000 on PyPI
valkeyPython client library for connecting to and…
permissive · top 5,000 on PyPI
django-cache-urlConfigures Django cache backends from…
permissive · top 15,000 on PyPI
libvalkeylibvalkey is a Python C extension that…
permissive · top 5,000 on PyPI
cachelibCacheLib provides a unified API for interacting…
permissive · top 5,000 on PyPI
aiocacheProvides asyncio-compatible caching with…
unclear · top 5,000 on PyPI
opentelemetry-python-contrib-external-valkeyAdds OpenTelemetry tracing to the Valkey Python…
permissive · top 15,000 on PyPI
valkey-glideValkey GLIDE is an official async and sync…
permissive · top 5,000 on PyPI
fakeredisfakeredis provides an in-memory, pure-Python…
permissive · top 1,000 on PyPI
django-constanceDjango-constance lets you store and manage…
permissive · top 5,000 on PyPI