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


Python cache.CacheManager方法代码示例

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


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

示例1: __init__

# 需要导入模块: from beaker import cache [as 别名]
# 或者: from beaker.cache import CacheManager [as 别名]
def __init__(self, cache):
        if not has_beaker:
            raise exceptions.RuntimeException(
                "Can't initialize Beaker plugin; Beaker is not installed."
            )
        global _beaker_cache
        if _beaker_cache is None:
            if "manager" in cache.template.cache_args:
                _beaker_cache = cache.template.cache_args["manager"]
            else:
                _beaker_cache = beaker_cache.CacheManager()
        super(BeakerCacheImpl, self).__init__(cache) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:14,代码来源:beaker_cache.py

示例2: __init__

# 需要导入模块: from beaker import cache [as 别名]
# 或者: from beaker.cache import CacheManager [as 别名]
def __init__(self, cache):
        if not has_beaker:
            raise exceptions.RuntimeException(
                "Can't initialize Beaker plugin; Beaker is not installed.")
        global _beaker_cache
        if _beaker_cache is None:
            if 'manager' in cache.template.cache_args:
                _beaker_cache = cache.template.cache_args['manager']
            else:
                _beaker_cache = beaker_cache.CacheManager()
        super(BeakerCacheImpl, self).__init__(cache) 
开发者ID:jpush,项目名称:jbox,代码行数:13,代码来源:beaker_cache.py

示例3: __init__

# 需要导入模块: from beaker import cache [as 别名]
# 或者: from beaker.cache import CacheManager [as 别名]
def __init__(self, app, config=None, environ_key='beaker.cache', **kwargs):
        """Initialize the Cache Middleware

        The Cache middleware will make a CacheManager instance available
        every request under the ``environ['beaker.cache']`` key by
        default. The location in environ can be changed by setting
        ``environ_key``.

        ``config``
            dict  All settings should be prefixed by 'cache.'. This
            method of passing variables is intended for Paste and other
            setups that accumulate multiple component settings in a
            single dictionary. If config contains *no cache. prefixed
            args*, then *all* of the config options will be used to
            intialize the Cache objects.

        ``environ_key``
            Location where the Cache instance will keyed in the WSGI
            environ

        ``**kwargs``
            All keyword arguments are assumed to be cache settings and
            will override any settings found in ``config``

        """
        self.app = app
        config = config or {}

        self.options = {}

        # Update the options with the parsed config
        self.options.update(parse_cache_config_options(config))

        # Add any options from kwargs, but leave out the defaults this
        # time
        self.options.update(
            parse_cache_config_options(kwargs, include_defaults=False))

        # Assume all keys are intended for cache if none are prefixed with
        # 'cache.'
        if not self.options and config:
            self.options = config

        self.options.update(kwargs)
        self.cache_manager = CacheManager(**self.options)
        self.environ_key = environ_key 
开发者ID:abdesslem,项目名称:malwareHunter,代码行数:48,代码来源:middleware.py

示例4: __init__

# 需要导入模块: from beaker import cache [as 别名]
# 或者: from beaker.cache import CacheManager [as 别名]
def __init__(self):
        """
        Reads config, creates DB session, and initializes cache
        """
        self.config_file_name = 'augur.config.json'
        self.__shell_config = None
        self.__export_file = None
        self.__env_file = None
        self.config = default_config
        self.env_config = {}
        self.root_augur_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
        default_config_path = self.root_augur_dir + '/' + self.config_file_name
        using_config_file = False


        config_locations = [self.config_file_name, default_config_path, f"/opt/augur/{self.config_file_name}"]
        if os.getenv('AUGUR_CONFIG_FILE') is not None:
            config_file_path = os.getenv('AUGUR_CONFIG_FILE')
            using_config_file = True
        else:
            for index, location in enumerate(config_locations):
                try:
                    f = open(location, "r+")
                    config_file_path = os.path.abspath(location)
                    using_config_file = True
                    f.close()
                    break
                except FileNotFoundError:
                    pass

        if using_config_file:
            try:
                with open(config_file_path, 'r+') as config_file_handle:
                    self.config = json.loads(config_file_handle.read())
            except json.decoder.JSONDecodeError as e:
                logger.warn('%s could not be parsed, using defaults. Fix that file, or delete it and run this again to regenerate it. Error: %s', config_file_path, str(e))
        else:
            logger.warn('%s could not be parsed, using defaults.')

        self.load_env_configuration()

        # List of data sources that can do periodic updates

        self.cache_config = {
            'cache.type': 'file',
            'cache.data_dir': 'runtime/cache/',
            'cache.lock_dir': 'runtime/cache/'
        }
        if not os.path.exists(self.cache_config['cache.data_dir']):
            os.makedirs(self.cache_config['cache.data_dir'])
        if not os.path.exists(self.cache_config['cache.lock_dir']):
            os.makedirs(self.cache_config['cache.lock_dir'])
        cache_parsed = parse_cache_config_options(self.cache_config)
        self.cache = CacheManager(**cache_parsed)

        self.metrics = MetricDefinitions(self) 
开发者ID:chaoss,项目名称:augur,代码行数:58,代码来源:application.py


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