Python werkzeug.contrib.cache 模块,SimpleCache() 实例源码

我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用werkzeug.contrib.cache.SimpleCache()

项目:flask-ask    作者:johnwheeler    | 项目源码 | 文件源码
def __init__(self, app=None, route=None, blueprint=None, stream_cache=None, path='templates.yaml'):
        self.app = app
        self._route = route
        self._intent_view_funcs = {}
        self._intent_converts = {}
        self._intent_defaults = {}
        self._intent_mappings = {}
        self._launch_view_func = None
        self._session_ended_view_func = None
        self._on_session_started_callback = None
        self._default_intent_view_func = None
        self._player_request_view_funcs = {}
        self._player_mappings = {}
        self._player_converts = {}
        if app is not None:
            self.init_app(app, path)
        elif blueprint is not None:
            self.init_blueprint(blueprint, path)
        if stream_cache is None:
            self.stream_cache = SimpleCache()
        else:
            self.stream_cache = stream_cache
项目:enjoliver    作者:JulienBalestra    | 项目源码 | 文件源码
def __init__(self, api_uri: str, matchbox_path: str, ignition_dict: dict, extra_selector_dict=None):
        """
        :param api_uri: http://1.1.1.1:5000
        :param matchbox_path: /var/lib/matchbox
        :param ignition_dict: ignition.yaml
        """
        self.api_uri = api_uri
        os.environ["API_URI"] = self.api_uri
        self.matchbox_path = matchbox_path
        self.ignition_dict = ignition_dict
        self._reporting_ignitions()
        self.extra_selector = extra_selector_dict if extra_selector_dict else {}
        # inMemory cache for http queries
        if EC.sync_cache_ttl > 0:
            self._cache_query = SimpleCache(default_timeout=EC.sync_cache_ttl)
        else:
            self._cache_query = NullCache()
项目:Emoji-Web    作者:emoji-gen    | 项目源码 | 文件源码
def make_cache():
    timeout = app.config['CACHE_TIMEOUT']
    if app.config['MEMCACHED_ENABLED']:
        hosts = app.config['MEMCACHED_HOSTS']
        return BinarySupportedMemcachedCache(hosts, default_timeout=timeout)

    return SimpleCache(default_timeout=timeout)
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def test_get_dict(self):
        c = cache.SimpleCache()
        c.set('a', 'a')
        c.set('b', 'b')
        d = c.get_dict('a', 'b')
        assert 'a' in d
        assert 'a' == d['a']
        assert 'b' in d
        assert 'b' == d['b']
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def test_set_many(self):
        c = cache.SimpleCache()
        c.set_many({0: 0, 1: 1, 2: 4})
        assert c.get(2) == 4
        c.set_many((i, i*i) for i in range(3))
        assert c.get(2) == 4
项目:gepify    作者:nvlbg    | 项目源码 | 文件源码
def setUp(self):
        songs.cache = SimpleCache()
项目:gepify    作者:nvlbg    | 项目源码 | 文件源码
def setUp(self):
        songs.cache = SimpleCache()
项目:gepify    作者:nvlbg    | 项目源码 | 文件源码
def setUp(self):
        playlists.cache = SimpleCache()
项目:gepify    作者:nvlbg    | 项目源码 | 文件源码
def setUp(self):
        playlists.cache = SimpleCache()
项目:FindYourCandy    作者:BrainPad    | 项目源码 | 文件源码
def __init__(self):
        self.cache = SimpleCache(default_timeout=1800)
项目:flask-ask    作者:johnwheeler    | 项目源码 | 文件源码
def setUp(self):
        self.patcher = patch('flask_ask.core.find_ask', return_value=Ask())
        self.ask = self.patcher.start()
        self.user_id = 'dave'
        self.token = '123-abc'
        self.cache = SimpleCache()
项目:ctfscoreboard    作者:google    | 项目源码 | 文件源码
def __init__(self, app):
        cache_type = app.config.get('CACHE_TYPE')
        if cache_type == 'memcached':
            host = app.config.get('MEMCACHE_HOST')
            self._cache = cache.MemcachedCache([host])
        elif cache_type == 'appengine':
            self._cache = cache.MemcachedCache()
        elif cache_type == 'local':
            self._cache = cache.SimpleCache()
        else:
            self._cache = cache.NullCache()
项目:flask-caching    作者:sh4nks    | 项目源码 | 文件源码
def test_dict_config_initapp(app):
    cache = Cache()
    cache.init_app(app, config={'CACHE_TYPE': 'simple'})
    from werkzeug.contrib.cache import SimpleCache
    assert isinstance(app.extensions['cache'][cache], SimpleCache)
项目:flask-caching    作者:sh4nks    | 项目源码 | 文件源码
def test_dict_config_both(app):
    cache = Cache(config={'CACHE_TYPE': 'null'})
    cache.init_app(app, config={'CACHE_TYPE': 'simple'})
    from werkzeug.contrib.cache import SimpleCache
    assert isinstance(app.extensions['cache'][cache], SimpleCache)
项目:Ostrich    作者:anantzoid    | 项目源码 | 文件源码
def __init__(self):
        if webapp.config['APP_ENV'] == 'dev':
            from werkzeug.contrib.cache import SimpleCache
            self.cache = SimpleCache()
        else:
            from werkzeug.contrib.cache import MemcachedCache
            self.cache = MemcachedCache(['127.0.0.1:11211'])