当前位置: 首页>>代码示例>>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;未经允许,请勿转载。