python类RedisCache()的实例源码

backends.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def redis(app, config, args, kwargs):
        kwargs.update(dict(
            host=config.get('CACHE_REDIS_HOST', 'localhost'),
            port=config.get('CACHE_REDIS_PORT', 6379),
        ))
        password = config.get('CACHE_REDIS_PASSWORD')
        if password:
            kwargs['password'] = password

        key_prefix = config.get('CACHE_KEY_PREFIX')
        if key_prefix:
            kwargs['key_prefix'] = key_prefix

        db_number = config.get('CACHE_REDIS_DB')
        if db_number:
            kwargs['db'] = db_number

        redis_url = config.get('CACHE_REDIS_URL')
        if redis_url:
            kwargs['host'] = redis_from_url(
                                redis_url,
                                db=kwargs.pop('db', None),
                            )

        return RedisCache(*args, **kwargs)
backends.py 文件源码 项目:FileStoreGAE 作者: liantian-cn 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def redis(app, config, args, kwargs):
        kwargs.update(dict(
            host=config.get('CACHE_REDIS_HOST', 'localhost'),
            port=config.get('CACHE_REDIS_PORT', 6379),
        ))
        password = config.get('CACHE_REDIS_PASSWORD')
        if password:
            kwargs['password'] = password

        key_prefix = config.get('CACHE_KEY_PREFIX')
        if key_prefix:
            kwargs['key_prefix'] = key_prefix

        db_number = config.get('CACHE_REDIS_DB')
        if db_number:
            kwargs['db'] = db_number

        redis_url = config.get('CACHE_REDIS_URL')
        if redis_url:
            kwargs['host'] = redis_from_url(
                                redis_url,
                                db=kwargs.pop('db', None),
                            )

        return RedisCache(*args, **kwargs)
cache.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def make_cache(self):
        return cache.RedisCache(key_prefix='werkzeug-test-case:')
backends.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def filesystem(app, config, args, kwargs):
    args.insert(0, config['CACHE_DIR'])
    kwargs.update(dict(threshold=config['CACHE_THRESHOLD']))
    return FileSystemCache(*args, **kwargs)

# RedisCache is supported since Werkzeug 0.7.
backends.py 文件源码 项目:FileStoreGAE 作者: liantian-cn 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def filesystem(app, config, args, kwargs):
    args.insert(0, config['CACHE_DIR'])
    kwargs.update(dict(threshold=config['CACHE_THRESHOLD']))
    return FileSystemCache(*args, **kwargs)

# RedisCache is supported since Werkzeug 0.7.
testredis.py 文件源码 项目:edmunds 作者: LowieHuyghe 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_redis(self):
        """
        Test the redis
        """

        # Write config
        self.write_config([
            "from edmunds.cache.drivers.redis import Redis \n",
            "APP = { \n",
            "   'cache': { \n",
            "       'enabled': True, \n",
            "       'instances': [ \n",
            "           { \n",
            "               'name': 'redis',\n",
            "               'driver': Redis,\n",
            "               'host': 'localhost',\n",
            "               'port': 6379,\n",
            "               'password': None,\n",
            "               'db': 0,\n",
            "               'default_timeout': 300,\n",
            "               'key_prefix': None,\n",
            "           }, \n",
            "       ], \n",
            "   }, \n",
            "} \n",
            ])

        # Create app
        app = self.create_application()

        driver = app.cache()
        self.assert_is_instance(driver, Redis)
        self.assert_is_instance(driver, RedisCache)
cache.py 文件源码 项目:website 作者: DiscordEmotes 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_redis():
    if not hasattr(current_app, 'redis'):
        host, port = current_app.config["REDIS_CONN"]
        cache = RedisCache(host, port, default_timeout=300)

        current_app.redis = cache

    return current_app.redis


问题


面经


文章

微信
公众号

扫码关注公众号