skillfed

django-valkey

a valkey backend for django

django-valkey v0.4.1 77.7K downloads/30d#14,502 on PyPI81
Permissive license BSD-3-Clause Active released

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-valkey

uv

uv add django-valkey

poetry

poetry add django-valkey

Installing 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

Development Status :: 4 - BetaEnvironment :: Web EnvironmentFramework :: Django :: 4.2Framework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: LibrariesTopic :: Utilities

Tags

django cache backend valkeyvalkey session storage djangoredis alternative django cachingdjango key-value storevalkey django integrationdistributed cache djangodjango async cache
django-integrationcaching-backendsession-storage

More Libraries packages