def redis_cache(event_loop): cache = RedisCache(namespace="test") yield cache event_loop.run_until_complete(cache.delete(pytest.KEY)) event_loop.run_until_complete(cache.delete(pytest.KEY_1)) event_loop.run_until_complete(cache.delete(pytest.KEY + '-lock')) event_loop.run_until_complete(cache.close())
def redis_cache(event_loop): cache = RedisCache(namespace="test", loop=event_loop) yield cache event_loop.run_until_complete(cache.delete(pytest.KEY)) event_loop.run_until_complete(cache.delete(pytest.KEY_1)) for _, pool in RedisBackend.pools.items(): pool.close() event_loop.run_until_complete(pool.wait_closed())
def redis_cache(event_loop): cache = RedisCache(namespace="test", loop=event_loop) cache.set_policy(DefaultPolicy) yield cache event_loop.run_until_complete(cache.delete(pytest.KEY)) event_loop.run_until_complete(cache.delete(pytest.KEY_1)) cache._backend._pool.close() event_loop.run_until_complete(cache._backend._pool.wait_closed())
def test_cached(): cache = RedisCache(endpoint="127.0.0.1", port=6379, namespace="main") loop = asyncio.get_event_loop() loop.run_until_complete(cached_call()) assert loop.run_until_complete(cache.exists("key")) is True loop.run_until_complete(cache.delete("key")) loop.run_until_complete(cache.close())
def test_alias(): loop = asyncio.get_event_loop() loop.run_until_complete(default_cache()) loop.run_until_complete(alt_cache()) cache = RedisCache() loop.run_until_complete(cache.delete("key")) loop.run_until_complete(cache.close()) loop.run_until_complete(caches.get('default').close())