valkey-redis-compat
Drop-in redis-py replacement backed by valkey-py.
Migrate from Redis to Valkey without changing a single line of application code.
Русская версия / Russian version
What it does
| Layer | Before | After |
|---|---|---|
import redis |
loads redis-py |
loads valkey-py via this shim |
redis.Redis(...) |
redis.client.Redis |
valkey.client.Valkey (API-compatible) |
| kombu broker transport | redis:// only |
works through the shim |
flask-caching RedisCache |
needs redis-py |
works through the shim |
The package patches importlib.metadata.version("redis") so that libraries like kombu, which check the installed redis version at import time, work without issues.
Installation
pip install valkey-redis-compat
Quick start
Nothing changes in your application code:
import redis
r = redis.Redis(host="localhost", port=6379, db=0)
r.set("key", "value")
print(r.get("key")) # b'value'
Under the hood every call goes through valkey-py.
kombu / Celery broker
kombu uses import redis internally for the redis:// broker transport — the shim handles this transparently.
To use valkey:// URLs as a broker, register the transport alias before Celery starts:
from kombu.transport import TRANSPORT_ALIASES
TRANSPORT_ALIASES.setdefault("valkey", "kombu.transport.redis:Transport")
TRANSPORT_ALIASES.setdefault("valkeys", "kombu.transport.redis:Transport")
flask-caching
No changes needed — RedisCache / RedisSentinelCache import redis internally, which this package provides.
Shim coverage
Every public valkey-py submodule is re-exported under the redis namespace:
redis.* |
maps to |
|---|---|
redis |
valkey |
redis.asyncio |
valkey.asyncio |
redis.backoff |
valkey.backoff |
redis.client |
valkey.client |
redis.cluster |
valkey.cluster |
redis.commands |
valkey.commands |
redis.connection |
valkey.connection |
redis.credentials |
valkey.credentials |
redis.exceptions |
valkey.exceptions |
redis.lock |
valkey.lock |
redis.retry |
valkey.retry |
redis.sentinel |
valkey.sentinel |
redis.typing |
valkey.typing |
redis.utils |
valkey.utils |
Nested submodules (redis.asyncio.client, redis.commands.search, etc.) are also covered.
Why not just import valkey as redis?
That works for your code.
It does not work for third-party libraries (kombu, flask-caching, celery) that hardcode import redis internally.
This package solves both cases at once.
Compatibility
- Python 3.9 -- 3.13
- valkey-py >= 6.1.1
- Tested with kombu 5.x, flask-caching 2.x
License
MIT
Metadata
Release files for valkey-redis-compat 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| valkey_redis_compat-0.1.2.tar.gz | 15.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| valkey_redis_compat-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.2 kB
Release files / valkey_redis_compat-0.1.2.tar.gz
| Download URL | valkey_redis_compat-0.1.2.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af6cdaa4baff0b8cdd64aa24811a4a16559fbb99777171979363d50f2cca8d05
|
|
BLAKE2b-256 checksum How to use checksums |
8cbb45ff05e6e9a61310c04bc2a6dff0a5d78ab37c68bedda31f87ed00181551
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / valkey_redis_compat-0.1.2-py3-none-any.whl
| Download URL | valkey_redis_compat-0.1.2-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91387d4228ba5e59bc297a939df7c0e4e68fe71e9d158968a4d1c2f36531fb63
|
|
BLAKE2b-256 checksum How to use checksums |
62aea41ffc370342f0bb05ececa4ac8aef7fa1e0cc91a464944ceff0a9f0d295
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for valkey-redis-compat 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.