當前位置: 首頁>>代碼示例>>Python>>正文


Python cache.SimpleCache方法代碼示例

本文整理匯總了Python中werkzeug.contrib.cache.SimpleCache方法的典型用法代碼示例。如果您正苦於以下問題:Python cache.SimpleCache方法的具體用法?Python cache.SimpleCache怎麽用?Python cache.SimpleCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在werkzeug.contrib.cache的用法示例。


在下文中一共展示了cache.SimpleCache方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from werkzeug.contrib import cache [as 別名]
# 或者: from werkzeug.contrib.cache import SimpleCache [as 別名]
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 
開發者ID:johnwheeler,項目名稱:flask-ask,代碼行數:24,代碼來源:core.py

示例2: __simple_cache

# 需要導入模塊: from werkzeug.contrib import cache [as 別名]
# 或者: from werkzeug.contrib.cache import SimpleCache [as 別名]
def __simple_cache(self):
        from werkzeug.contrib.cache import SimpleCache
        return SimpleCache() 
開發者ID:staugur,項目名稱:IncetOps,代碼行數:5,代碼來源:base.py

示例3: __init__

# 需要導入模塊: from werkzeug.contrib import cache [as 別名]
# 或者: from werkzeug.contrib.cache import SimpleCache [as 別名]
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 == 'local':
            self._cache = cache.SimpleCache()
        else:
            self._cache = cache.NullCache() 
開發者ID:google,項目名稱:ctfscoreboard,代碼行數:11,代碼來源:cache.py

示例4: setUp

# 需要導入模塊: from werkzeug.contrib import cache [as 別名]
# 或者: from werkzeug.contrib.cache import SimpleCache [as 別名]
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() 
開發者ID:johnwheeler,項目名稱:flask-ask,代碼行數:8,代碼來源:test_cache.py

示例5: __init__

# 需要導入模塊: from werkzeug.contrib import cache [as 別名]
# 或者: from werkzeug.contrib.cache import SimpleCache [as 別名]
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']) 
開發者ID:anantzoid,項目名稱:Ostrich,代碼行數:9,代碼來源:cache.py

示例6: test_get_dict

# 需要導入模塊: from werkzeug.contrib import cache [as 別名]
# 或者: from werkzeug.contrib.cache import SimpleCache [as 別名]
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'] 
開發者ID:GeekTrainer,項目名稱:Flask,代碼行數:11,代碼來源:cache.py

示例7: test_set_many

# 需要導入模塊: from werkzeug.contrib import cache [as 別名]
# 或者: from werkzeug.contrib.cache import SimpleCache [as 別名]
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 
開發者ID:GeekTrainer,項目名稱:Flask,代碼行數:8,代碼來源:cache.py

示例8: get_token_store

# 需要導入模塊: from werkzeug.contrib import cache [as 別名]
# 或者: from werkzeug.contrib.cache import SimpleCache [as 別名]
def get_token_store() -> BaseCache:
    """Get the configured token store, an instance of
    :class:`werkzeug.contrib.cache.BaseCache`.

    It raises :exc:`RuntimeError` if ``'TOKEN_STORE'`` is not configured,
    but it just warns :exc:`RuntimeWarning` when it comes to debug mode.

    :return: the configured session store
    :rtype: :class:`werkzeug.contrib.cache.BaseCache`
    :raise RuntimeError: when ``'TOKEN_STORE'`` is not configured, or
                         the value is not an instance of
                         :class:`werkzeug.contrib.cache.BaseCache`

    .. todo::

       Change the backend system from :mod:`werzkeug.contrib.cache`
       to :mod:`dogpile.cache`.

    """
    try:
        store = app.config['TOKEN_STORE']
    except KeyError:
        if app.debug:
            warnings.warn(
                'TOKEN_STORE configuration is not present, so use '
                '{0.__module__}.{0.__qualname__} instead.  This defaulting is '
                'only for debug purpose, and you must not expect it from '
                'production mode'.format(SimpleCache),
                RuntimeWarning
            )
            store = SimpleCache()
            app.config['TOKEN_STORE'] = store
        else:
            raise RuntimeError('TOKEN_STORE configuration is not present')
    if isinstance(store, BaseCache):
        return store
    raise RuntimeError(
        'TOKEN_STORE configuration must be an instance of {0.__module__}.'
        '{0.__qualname__}, not {1!r}'.format(BaseCache, store)
    )


#: The named tuple type that stores a token. 
開發者ID:spoqa,項目名稱:geofront,代碼行數:45,代碼來源:server.py

示例9: create_app

# 需要導入模塊: from werkzeug.contrib import cache [as 別名]
# 或者: from werkzeug.contrib.cache import SimpleCache [as 別名]
def create_app(settings_override=None):
    """
    Create a Flask application using the app factory pattern.
    :param settings_override: Override settings
    :return: Flask app
    """
    app = Flask(__name__, instance_relative_config=True)

    def disable_varnish(response):
        response.cache_control.private = True
        return response
    app.after_request(disable_varnish)

    SSLify(app, skips=['healthcheck'])
    gunicorn_logger = logging.getLogger('gunicorn.error')
    app.logger.handlers = gunicorn_logger.handlers
    app.logger.setLevel(gunicorn_logger.level)

    app.config.from_object('config.settings')

    if 'GOOGLE_CLIENT_ID' in app.config:
        setup_authentication(app)

    app.register_blueprint(page)

    plugins = {}
    for plugin in app.config['ENABLED_PLUGINS']:
        module = importlib.import_module(f'dashboard.plugins.{plugin}')
        app.register_blueprint(module.plugin, url_prefix=module.base_path)
        if hasattr(module, 'init'):
            module.init(app)
        plugins[plugin] = {'tab_name': module.tab_name}

    app.airflow_data_provider = AirflowDBDataProvider(app.config, app.logger, MySQLClient(app.config, app.logger))
    app.influx_client = InfluxDbService(app.config, app.logger) if app.config.get('INFLUXDB_HOST') else None
    app.influx_data_provider = InfluxDBData(app.influx_client, app.logger) if app.config.get('INFLUXDB_HOST') else None
    app.prometheus_data_provider = PrometheusData(app.config, app.logger) if app.config.get('PROMETHEUS_HOST') else None
    
    # Reading tables configs, setting variable to `None` if file is not present
    tables = get_yaml_file_content(TABLES_PATH)

    app.table_data_provider = TableDataProvider(
        app.airflow_data_provider, app.influx_data_provider,
        app.prometheus_data_provider, tables, app.logger, app.config) if tables else None

    links = get_yaml_file_content(LINKS_PATH)
    app.links_data_provider = LinksDataProvider(links)

    app.etl_data_provider = EtlDataProvider(
        app.config, app.airflow_data_provider, app.table_data_provider)

    app.async_request_executor = ThreadPoolExecutor(max_workers=3)
    app.cache = SimpleCache()

    if app.debug:
        app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)

    app.context_processor(lambda: {'now': datetime.now(), 'plugins': plugins})

    return app 
開發者ID:Wikia,項目名稱:discreETLy,代碼行數:62,代碼來源:app.py


注:本文中的werkzeug.contrib.cache.SimpleCache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。