系统缓存 :return: cache 连接池
()
| 26 | |
| 27 | |
| 28 | async def code_cache() -> Redis: |
| 29 | """ |
| 30 | 系统缓存 |
| 31 | :return: cache 连接池 |
| 32 | """ |
| 33 | # 从URL方式创建redis连接池 |
| 34 | sys_cache_pool = aioredis.ConnectionPool.from_url( |
| 35 | f"redis://{os.getenv('CACHE_HOST', '127.0.0.1')}:{os.getenv('CACHE_PORT', 6379)}", |
| 36 | db=os.getenv('CACHE_DB', 1), |
| 37 | encoding='utf-8', |
| 38 | decode_responses=True |
| 39 | ) |
| 40 | return Redis(connection_pool=sys_cache_pool) |