coredis is a fast, async, and fully-typed Redis client for Python, offering support for Redis Cluster, Sentinel, and various Redis modules. It is built with structured concurrency using `anyio`, supporting both `asyncio` and `trio`. The library is actively maintained with frequent releases, often multiple times a month for bug fixes and minor features, with major architectural rewrites released periodically. The current version is 6.5.1.
pip install coredisVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates connecting to a single Redis instance, performing basic `SET`, `GET`, `INCR` operations, and using a command pipeline. It leverages `anyio.run` to execute the asynchronous code and uses `os.environ.get` for flexible Redis URL configuration.
Refer to the official 'Migrating from 5.x to 6.0' guide in the coredis documentation for detailed upgrade instructions. Update your async code to follow `anyio`'s structured concurrency patterns, typically using `async with client:` for resource management.
Update your import statements to reflect the new `coredis.patterns` module path. For example, `from coredis.pipeline import Pipeline` becomes `from coredis.patterns import Pipeline`.
Upgrade to coredis version 6.5.1 or newer to fix this regression.
Upgrade to coredis version 6.2.0 or newer to ensure proper connection pool task group cleanup and recovery from initialization errors.
Upgrade to coredis version 6.1.0 or newer to resolve this issue and ensure correct connection capacity limiting.
Upgrade to coredis version 5.7.0 or newer. Ensure the URL contains credentials (e.g., `redis://user:password@host:port`) or pass them explicitly and correctly.
Ensure you have the latest stable version of coredis installed. Upgrade using `pip install --upgrade coredis`.
Provide the full hostname/endpoint when configuring the SSL connection. For example, `coredis.Redis(host='your-endpoint.redis.cache.amazonaws.com', port=6380, ssl=True, server_hostname='your-endpoint.redis.cache.amazonaws.com', password='your_password')`. Ensure no unescaped special characters like '#' are in the password if using a URI.
Verify that the Redis Cluster nodes are running and reachable from the client, and that the provided host/port configurations are correct. Ensure your Redis Cluster version is 6.x or newer, or explicitly configure `protocol_version=2` if using Redis 5.x. Check firewall rules and network connectivity. For `coredis` v6.2.0 and later, the base exception name is `coredis.exceptions.RedisClusterError` (an alias for older `RedisClusterException` is maintained).
Ensure the `password` (and `username` if using Redis ACLs) provided during client initialization matches the configuration of your Redis server. Example: `client = coredis.Redis(host='localhost', port=6379, password='correct_password')`.