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

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

项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def make_cache(self):
        return cache.MemcachedCache(key_prefix='werkzeug-test-case:')
项目: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()
项目:simple-qq-bot    作者:ihciah    | 项目源码 | 文件源码
def __init__(self):
        self.cache = MemcachedCache(['127.0.0.1:11211'])
项目:edmunds    作者:LowieHuyghe    | 项目源码 | 文件源码
def test_memcached(self):
        """
        Test the memcached
        """

        # Write config
        self.write_config([
            "from edmunds.cache.drivers.memcached import Memcached \n",
            "APP = { \n",
            "   'cache': { \n",
            "       'enabled': True, \n",
            "       'instances': [ \n",
            "           { \n",
            "               'name': 'memcached',\n",
            "               'driver': Memcached,\n",
            "               'servers': ['127.0.0.1:11211'], \n",
            "               'default_timeout': 300, \n",
            "               'key_prefix': None, \n",
            "           }, \n",
            "       ], \n",
            "   }, \n",
            "} \n",
            ])

        # Create app
        app = self.create_application()

        driver = app.cache()
        self.assert_is_instance(driver, Memcached)
        self.assert_is_instance(driver, MemcachedCache)
项目:edmunds    作者:LowieHuyghe    | 项目源码 | 文件源码
def test_memcached_in_gae(self):
        """
        Test the memcached in Google App Engine
        """

        # Write config
        self.write_config([
            "from edmunds.cache.drivers.memcached import Memcached \n",
            "APP = { \n",
            "   'cache': { \n",
            "       'enabled': True, \n",
            "       'instances': [ \n",
            "           { \n",
            "               'name': 'memcached',\n",
            "               'driver': Memcached,\n",
            "           }, \n",
            "       ], \n",
            "   }, \n",
            "} \n",
            ])

        # Create app
        app = self.create_application()

        driver = app.cache()
        self.assert_is_instance(driver, Memcached)
        self.assert_is_instance(driver, MemcachedCache)
        self.assert_is_instance(driver._client, memcache.Client)
项目: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'])