aioredis is an `asyncio` (PEP 3156) Redis client library providing asynchronous support for Redis. Currently at version 2.0.1, it underwent a complete rewrite in version 2.0.0 to align its API closely with the `redis-py` library, making it easier to adapt synchronous `redis-py` code for async applications. It is actively maintained with frequent updates.
pip install aioredisVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates connecting to Redis using `aioredis.from_url`, setting and retrieving a key, and using a transaction pipeline. It emphasizes graceful connection shutdown and the recommended `decode_responses` parameter for automatic string decoding.
Refer to the official 'Migrating to v2.0' documentation. Key changes include connection methods, connection pool behavior, and command arguments.
Use `aioredis.from_url()` to get a client with a connection pool, or `aioredis.Redis()` with an explicit `ConnectionPool` instance.
Remove the `loop` argument from all `aioredis` function calls. Code should run in the current running event loop.
Understand that `minsize` will not immediately establish connections in v2.x. Adjust application startup logic if pre-established connections are critical for initial performance checks.
Refactor PubSub code to use `redis.pubsub()` directly, similar to `redis-py`'s PubSub client.
Initialize your Redis client with `redis = aioredis.from_url('redis://localhost', decode_responses=True)` to get string responses automatically. Otherwise, manually decode byte strings using `.decode('utf-8')`.Ensure Python environment is 3.6+ and update code to handle the new return formats for affected commands.