Пример #1
0
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())
Пример #2
0
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())
Пример #3
0
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())
Пример #4
0
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())
Пример #5
0
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())