redis 4.2.0 merged aioredis-迁移小计
背景
Add Async Support #1899
https://github.com/redis/redis-py/pull/1899
Version 4.2.0-rc1
https://github.com/redis/redis-py/releases/tag/v4.2.0rc1
迁移
官方做法
https://github.com/aio-libs/aioredis-py
Aioredis is now in redis-py 4.2.0rc1+
To install, just do pip install redis>=4.2.0rc1. The code is almost the exact same. You will just need to import like so:
from redis import asyncio as aioredis
This way you don’t have to change all your code, just the imports.
我的做法
统一使用redis库,去掉aioredis库及概念,适用于仅用异步方式使用redis场景。
aioredis【迁移前】
1 | # 引入库 |
redis 【迁移后】
1 | import redis.asyncio as redis |