我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用werkzeug.contrib.cache.SimpleCache()。
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
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()
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)
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']
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
def setUp(self): songs.cache = SimpleCache()
def setUp(self): playlists.cache = SimpleCache()
def __init__(self): self.cache = SimpleCache(default_timeout=1800)
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()
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()
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)
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)
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'])