当前位置: 首页>>代码示例>>Python>>正文


Python cache.make_region方法代码示例

本文整理汇总了Python中dogpile.cache.make_region方法的典型用法代码示例。如果您正苦于以下问题:Python cache.make_region方法的具体用法?Python cache.make_region怎么用?Python cache.make_region使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dogpile.cache的用法示例。


在下文中一共展示了cache.make_region方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_cache

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def create_cache(name):
    ch = None

    if force_redis:
        ch = make_region().configure(
            'dogpile.cache.redis',
            arguments=force_redis
        )
    else:
        try:
            ch = get_region(name)
        except:
            ch = make_region().configure('dogpile.cache.memory')
            warnings.warn("Warning: cache objects are in memory, are you creating docs?")

    ch.key_mangler = my_key_mangler(name)
    
    return ch 
开发者ID:ActiDoo,项目名称:gamification-engine,代码行数:20,代码来源:cache.py

示例2: __init__

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def __init__(self, issuers_to_provider_ids, jwks_supplier, cache_capacity=200):
        """Construct an instance of AuthTokenDecoder.

        Args:
          issuers_to_provider_ids: a dictionary mapping from issuers to provider
            IDs defined in the service configuration.
          jwks_supplier: an instance of JwksSupplier that supplies JWKS based on
            issuer.
          cache_capacity: the cache_capacity with default value of 200.
        """
        self._issuers_to_provider_ids = issuers_to_provider_ids
        self._jwks_supplier = jwks_supplier

        arguments = {u"capacity": cache_capacity}
        expiration_time = datetime.timedelta(minutes=5)
        self._cache = cache.make_region().configure(u"lru_cache",
                                                    arguments=arguments,
                                                    expiration_time=expiration_time) 
开发者ID:cloudendpoints,项目名称:endpoints-management-python,代码行数:20,代码来源:tokens.py

示例3: test_instance_from_config_string

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def test_instance_from_config_string(self):
        my_conf = (
            "[xyz]\n"
            "cache.example.backend=mock\n"
            "cache.example.expiration_time=600\n"
            "cache.example.arguments.url=127.0.0.1\n"
            "cache.example.arguments.dogpile_lockfile=false\n"
            "cache.example.arguments.xyz=None\n"
        )

        my_region = make_region()
        config = configparser.ConfigParser()
        compat.read_config_file(config, io.StringIO(my_conf))

        my_region.configure_from_config(
            dict(config.items("xyz")), "cache.example."
        )
        eq_(my_region.expiration_time, 600)
        assert isinstance(my_region.backend, MockBackend) is True
        eq_(
            my_region.backend.arguments,
            {"url": "127.0.0.1", "dogpile_lockfile": False, "xyz": None},
        ) 
开发者ID:sqlalchemy,项目名称:dogpile.cache,代码行数:25,代码来源:test_region.py

示例4: _regions

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def _regions(self):
        from dogpile.cache import make_region

        my_regions = {
            "short": make_region().configure(
                "dogpile.cache.memory", expiration_time=1
            ),
            "long": make_region().configure(
                "dogpile.cache.memory", expiration_time=60
            ),
            "myregion": make_region().configure(
                "dogpile.cache.memory", expiration_time=60
            ),
        }

        return my_regions 
开发者ID:sqlalchemy,项目名称:mako,代码行数:18,代码来源:test_cache.py

示例5: _regions

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def _regions(self):
        from dogpile.cache import make_region

        my_regions = {
            "short": make_region().configure(
                "dogpile.cache.memory",
                expiration_time=1
            ),
            "long": make_region().configure(
                "dogpile.cache.memory",
                expiration_time=60
            ),
            "myregion": make_region().configure(
                "dogpile.cache.memory",
                expiration_time=60
                )
        }

        return my_regions 
开发者ID:jhpyle,项目名称:docassemble,代码行数:21,代码来源:test_cache.py

示例6: test_to_repair_a_rule_with_only_1_rse_whose_site_is_blacklisted

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def test_to_repair_a_rule_with_only_1_rse_whose_site_is_blacklisted(self):
        """ JUDGE REPAIRER: Test to repair a rule with only 1 rse whose site is blacklisted"""

        rse = rse_name_generator()
        rse_id = add_rse(rse)
        update_rse(rse_id, {'availability_write': False})
        set_local_account_limit(self.jdoe, rse_id, -1)

        rule_repairer(once=True)  # Clean out the repairer
        scope = InternalScope('mock')
        files = create_files(4, scope, self.rse4_id, bytes=100)
        dataset = 'dataset_' + str(uuid())
        add_did(scope, dataset, DIDType.from_sym('DATASET'), self.jdoe)
        attach_dids(scope, dataset, files, self.jdoe)

        rule_id = add_rule(dids=[{'scope': scope, 'name': dataset}], account=self.jdoe, copies=1, rse_expression=rse, grouping='DATASET', weight=None, lifetime=None, locked=False, subscription_id=None, ignore_availability=True, activity='DebugJudge')[0]

        assert(RuleState.STUCK == get_rule(rule_id)['state'])
        rule_repairer(once=True)

        # Stil assert STUCK because of ignore_availability:
        assert(RuleState.STUCK == get_rule(rule_id)['state'])

        region = make_region().configure('dogpile.cache.memcached',
                                         expiration_time=3600,
                                         arguments={'url': config_get('cache', 'url', False, '127.0.0.1:11211'), 'distributed_lock': True})
        region.delete(sha256(rse.encode()).hexdigest())

        update_rse(rse_id, {'availability_write': True})
        rule_repairer(once=True)
        assert(RuleState.REPLICATING == get_rule(rule_id)['state']) 
开发者ID:rucio,项目名称:rucio,代码行数:33,代码来源:test_judge_repairer.py

示例7: __init__

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def __init__(self, key_uri_supplier):
        """Constructs an instance of JwksSupplier.

        Args:
          key_uri_supplier: a KeyUriSupplier instance that returns the `jwks_uri`
            based on the given issuer.
        """
        self._key_uri_supplier = key_uri_supplier
        self._jwks_cache = cache.make_region().configure(
            u"dogpile.cache.memory", expiration_time=datetime.timedelta(minutes=5)) 
开发者ID:cloudendpoints,项目名称:endpoints-management-python,代码行数:12,代码来源:suppliers.py

示例8: test_set_name

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def test_set_name(self):
        my_region = make_region(name="my-name")
        eq_(my_region.name, "my-name") 
开发者ID:sqlalchemy,项目名称:dogpile.cache,代码行数:5,代码来源:test_region.py

示例9: test_instance_from_dict

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def test_instance_from_dict(self):
        my_conf = {
            "cache.example.backend": "mock",
            "cache.example.expiration_time": 600,
            "cache.example.arguments.url": "127.0.0.1",
        }
        my_region = make_region()
        my_region.configure_from_config(my_conf, "cache.example.")
        eq_(my_region.expiration_time, 600)
        assert isinstance(my_region.backend, MockBackend) is True
        eq_(my_region.backend.arguments, {"url": "127.0.0.1"}) 
开发者ID:sqlalchemy,项目名称:dogpile.cache,代码行数:13,代码来源:test_region.py

示例10: test_datetime_expiration_time

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def test_datetime_expiration_time(self):
        my_region = make_region()
        my_region.configure(
            backend="mock", expiration_time=datetime.timedelta(days=1, hours=8)
        )
        eq_(my_region.expiration_time, 32 * 60 * 60) 
开发者ID:sqlalchemy,项目名称:dogpile.cache,代码行数:8,代码来源:test_region.py

示例11: test_reject_invalid_expiration_time

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def test_reject_invalid_expiration_time(self):
        my_region = make_region()

        assert_raises_message(
            exception.ValidationError,
            "expiration_time is not a number or timedelta.",
            my_region.configure,
            "mock",
            "one hour",
        ) 
开发者ID:sqlalchemy,项目名称:dogpile.cache,代码行数:12,代码来源:test_region.py

示例12: get_cache_backend

# 需要导入模块: from dogpile import cache [as 别名]
# 或者: from dogpile.cache import make_region [as 别名]
def get_cache_backend() -> CacheRegion:
    """
    Get a dogpilecache cache region.

    Returns
    -------
    CacheRegion
    """
    cache_backend = getenv("FLOWAUTH_CACHE_BACKEND", "FILE").upper()

    if cache_backend == "REDIS":
        backend = "dogpile.cache.redis"
        cache_args = dict(
            host=environ["FLOWAUTH_REDIS_HOST"],
            port=int(getenv("FLOWAUTH_REDIS_PORT", "6379")),
            db=int(getenv("FLOWAUTH_REDIS_DB", "0")),
            redis_expiration_time=32,
            distributed_lock=True,
            password=getenv("FLOWAUTH_REDIS_PASSWORD", None),
        )
    elif cache_backend == "FILE":
        backend = "dogpile.cache.dbm"
        cache_args = dict(filename=environ["FLOWAUTH_CACHE_FILE"])
    else:
        backend = "dogpile.cache.memory"
        cache_args = {}

    return make_region().configure(
        backend=backend, expiration_time=30, arguments=cache_args
    )


# Duplicated in flowkit_jwt_generator (cannot re-use the implementation
# there because the module is outside the docker build context for flowauth). 
开发者ID:Flowminder,项目名称:FlowKit,代码行数:36,代码来源:config.py


注:本文中的dogpile.cache.make_region方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。