migrate-redis-py
Migrating from redis-py to Valkey GLIDE (Python)
Use when migrating a Python application from redis-py to the GLIDE client library.
Routing
- String, hash, list, set, sorted set, delete, exists, cluster -> API Mapping
- Pipeline, transaction, Batch API -> Advanced Patterns
- PubSub, subscribe, publish, dynamic subscriptions -> Advanced Patterns
Key Differences
| Area | redis-py | GLIDE |
|---|---|---|
| Default mode | Synchronous | Async-first (sync API from GLIDE 2.1) |
| Return type | Strings (with decode_responses=True) | Bytes always - call .decode() |
| Multi-arg commands | Varargs: delete("k1", "k2") | List args: delete(["k1", "k2"]) |
| Expiry | Keyword args: ex=60 | ExpirySet objects |
| Conditional SET | Separate setnx(), setex() | Enum options on set() |
| Connection model | Connection pool (default 10 conns) | Single multiplexed connection per node |
| Cluster client | redis.RedisCluster() | GlideClusterClient with auto-topology |
Quick Start - Connection Setup
redis-py:
import redis
r = redis.Redis(host="localhost", port=6379, db=0, decode_responses=True)
r.ping()
GLIDE (async):
from glide import GlideClient, GlideClientConfiguration, NodeAddress
config = GlideClientConfiguration(
addresses=[NodeAddress("localhost", 6379)], database_id=0, request_timeout=5000)
client = await GlideClient.create(config)
await client.ping()
GLIDE (sync - 2.1+):
from glide_sync import GlideClient, GlideClientConfiguration, NodeAddress
config = GlideClientConfiguration(
addresses=[NodeAddress("localhost", 6379)], database_id=0)
client = GlideClient.create(config)
client.ping()
Configuration Mapping
| redis-py parameter | GLIDE equivalent |
|---|---|
| host, port | NodeAddress(host, port) in addresses list |
| db | database_id |
| password | ServerCredentials(password=...) in credentials |
| username | ServerCredentials(username=..., password=...) |
| socket_timeout | request_timeout (milliseconds, not seconds) |
| ssl=True | use_tls=True |
| retry_on_timeout | Built-in reconnection with BackoffStrategy |
| decode_responses | No equivalent - always returns bytes |
Incremental Migration Strategy
No drop-in replacement or compatibility layer exists for Python. Migration approach:
- Install
valkey-glidealongsideredis-py - Create a wrapper/adapter that abstracts the client interface
- Migrate command-by-command behind the adapter
- Use
asyncio.gather()or the Batch API for bulk operations - Swap out the adapter once all commands are migrated
- Remove
redis-pydependency
Reference
| Topic | File |
|---|---|
| Command-by-command API mapping (strings, hashes, lists, sets, sorted sets, delete, exists, cluster) | api-mapping |
| Pipelines, transactions, Pub/Sub, platform notes | advanced-patterns |
See Also
- valkey-glide-python skill - full GLIDE Python API details
- PubSub (see valkey-glide skill) - subscription patterns and dynamic PubSub
- Batching (see valkey-glide skill) - pipeline and transaction patterns
Gotchas
- Bytes everywhere. GLIDE has no decode_responses option. All string values return as bytes. Call .decode() at each read site.
- List arguments. Commands like delete, exists, lpush, sadd take a list, not varargs.
- No connection pool tuning. GLIDE uses a single multiplexed connection per node.
- Async by default. The primary API is async. The sync wrapper (glide_sync) is available from GLIDE 2.1.
- Timeout units. redis-py uses seconds (float). GLIDE uses milliseconds (int). Default is 250ms.
- No decode_responses shortcut. Add .decode() calls at each read site, or build a thin wrapper.
- Protobuf dependency conflict. Requires
protobuf>=3.20- pin versions carefully. - Alpine Linux not supported. GLIDE requires glibc 2.17+ - use Debian-based container images.
- Proxy incompatibility. GLIDE runs INFO REPLICATION and CLIENT commands during connection setup.
More from avifenesh/valkey-skills
valkey
Use when building apps with Valkey - caching, sessions, queues, locks, rate-limiting, leaderboards, counters, pub-sub, streams, scripting. Covers IFEQ/DELIFEQ, hash field TTL, COMMANDLOG. Not for server internals (valkey-dev) or ops (valkey-ops).
5valkey-dev
Use when contributing to the Valkey server - C internals, event loop, commands, data structures, cluster, replication, RDB/AOF, memory, threading, modules, Lua, RESP, tests. Not for app development (valkey) or ops (valkey-ops).
5valkey-ops
Use when deploying, configuring, monitoring, or troubleshooting self-hosted Valkey. Covers Sentinel, cluster, persistence, replication, security, Kubernetes, performance tuning. Not for app development (valkey) or server internals (valkey-dev).
5valkey-ecosystem
Use when evaluating the Valkey ecosystem - client libraries, modules (JSON, Bloom, Search), managed services (AWS, GCP, Aiven), monitoring tools, frameworks (Spring, Django, Rails), Docker/Kubernetes deployment, CI/CD patterns, migration from Redis, and developer tooling.
5glide-mq
Use when building message queues with glide-mq. Covers queue setup, producer/consumer patterns, job scheduling, workflows, batch processing, streaming, and suspend/resume. Not for migrating from BullMQ (migrate-bullmq) or Bee-Queue (migrate-bee).
4valkey-glide
Router for Valkey GLIDE per-language skills. Use when you need to find the right language-specific GLIDE skill or migration skill. Not for GLIDE library internals or contributing to GLIDE source code - use glide-dev instead.
4