12 lines
405 B
Python
12 lines
405 B
Python
"""Redis 异步客户端(缓存/计数/队列 Broker)"""
|
||
import redis.asyncio as aioredis
|
||
|
||
from app.config import settings
|
||
|
||
# protocol=2:服务器为 Redis 5.x,不支持 RESP3 的 HELLO 握手(redis-py 8.x 默认尝试 3)
|
||
redis_client: aioredis.Redis = aioredis.from_url(settings.redis_url, decode_responses=True, protocol=2)
|
||
|
||
|
||
async def get_redis() -> aioredis.Redis:
|
||
return redis_client
|