async def redis_cache() -> typing.AsyncGenerator[utils.RedisCache, None]: with utils.aredis_for_cache() as client: await client.flushdb() try: yield client finally: await client.flushdb() client.connection_pool.disconnect() await utils.stop_pending_aredis_tasks()
async def clear_redis_cache(): with utils.aredis_for_cache() as redis_stream: await redis_stream.flushall()