Example #1
0
def init_cache(sanic, loop):
    aiocache.settings.set_defaults(
        class_="aiocache.RedisCache",
        endpoint=REDIS_DICT.get('REDIS_ENDPOINT', None),
        port=REDIS_DICT.get('REDIS_PORT', None),
        db=REDIS_DICT.get('CACHE_DB', None),
        loop=loop,
    )
Example #2
0
    async def get_redis_pool(self):
        if not self._pool:
            self._pool = await asyncio_redis.Pool.create(
                host=REDIS_DICT.get('REDIS_ENDPOINT', None), port=REDIS_DICT.get('REDIS_PORT', None),
                poolsize=REDIS_DICT.get('POOLSIZE', None), password=REDIS_DICT.get('PASSWORD', None),
                db=REDIS_DICT.get('SESSION_DB', None)
            )

        return self._pool
Example #3
0
def init_cache(sanic, loop):
    LOGGER.info("Starting aiocache")
    aiocache.settings.set_defaults(
        class_="aiocache.RedisCache",
        endpoint=REDIS_DICT.get('REDIS_ENDPOINT', None),
        port=REDIS_DICT.get('REDIS_PORT', None),
        db=REDIS_DICT.get('CACHE_DB', None),
        password=REDIS_DICT.get('PASSWORD', None),
        loop=loop,
    )
    LOGGER.info("Starting redis pool")
    redis = RedisSession()
    # redis instance for app
    app.get_redis_pool = redis.get_redis_pool
    # pass the getter method for the connection pool into the session
    app.session_interface = RedisSessionInterface(app.get_redis_pool, expiry=86400)