Skip to main content

Drop-in redis-py replacement backed by valkey-py — migrate from Redis to Valkey without changing application code

Project description

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

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

valkey_redis_compat-0.1.1.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

valkey_redis_compat-0.1.1-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file valkey_redis_compat-0.1.1.tar.gz.

File metadata

  • Download URL: valkey_redis_compat-0.1.1.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for valkey_redis_compat-0.1.1.tar.gz
Algorithm Hash digest
SHA256 53068897a783a58bf2606de76aca4808aa42a9acab2c50f2a7d9ab04de9cc067
MD5 5e9cdfafb0e423917f3c1dac646803ba
BLAKE2b-256 a598af2b6d2b4ceded0e0ac49ea3858b48b47c01decb2ec85503ed4d4da3f77c

See more details on using hashes here.

File details

Details for the file valkey_redis_compat-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: valkey_redis_compat-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for valkey_redis_compat-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c3b142ffed3a59b0e3d7306a464dec45af3d1203d75bbac1b5d7e4d3bfe42ea4
MD5 bd1006fe5c591bdd01ca97433191e81b
BLAKE2b-256 b70db23692a27f44b5f9c9491960db40f4167ec85a0f65360956e4e249741c18

See more details on using hashes here.

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