Beispiel #1
0
def redis_cache(app):
    with app.app_context():
        cache.init_app(app,
                       config={
                           'CACHE_TYPE': 'redis',
                           'CACHE_REDIS_HOST': 'redis.cache',
                       })
        cache.clear()
        yield cache
        cache.clear()
        cache.init_app(app,
                       config={
                           'CACHE_TYPE': 'null',
                           'CACHE_NO_NULL_WARNING': True,
                       })
Beispiel #2
0
def redis_cache(app):
    with app.app_context():
        cache_subsystem.init_app(app)
        cache.init_app(
            app, config={"CACHE_TYPE": "redis", "CACHE_REDIS_HOST": "redis.cache"}
        )
        try:
            cache.clear()
        except redis.exceptions.ConnectionError:
            if EXTERNAL_SERVICES_SHOULD_BE_PRESENT:
                raise
            else:
                pytest.skip("Could not connect to Redis")
        yield cache
        cache.clear()
        cache.init_app(
            app, config={"CACHE_TYPE": "null", "CACHE_NO_NULL_WARNING": True}
        )