当前位置: 首页>>代码示例>>Python>>正文


Python pylibmc.Client方法代码示例

本文整理汇总了Python中pylibmc.Client方法的典型用法代码示例。如果您正苦于以下问题:Python pylibmc.Client方法的具体用法?Python pylibmc.Client怎么用?Python pylibmc.Client使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylibmc的用法示例。


在下文中一共展示了pylibmc.Client方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: import_preferred_memcache_lib

# 需要导入模块: import pylibmc [as 别名]
# 或者: from pylibmc import Client [as 别名]
def import_preferred_memcache_lib(self, servers):
        """Returns an initialized memcache client.  Used by the constructor."""
        try:
            import pylibmc
        except ImportError:
            pass
        else:
            return pylibmc.Client(servers)

        try:
            from google.appengine.api import memcache
        except ImportError:
            pass
        else:
            return memcache.Client()

        try:
            import memcache
        except ImportError:
            pass
        else:
            return memcache.Client(servers)


# backwards compatibility 
开发者ID:jojoin,项目名称:cutout,代码行数:27,代码来源:memcachedcache.py

示例2: clear_database

# 需要导入模块: import pylibmc [as 别名]
# 或者: from pylibmc import Client [as 别名]
def clear_database() -> None:
    # Hacky function only for use inside populate_db.  Designed to
    # allow running populate_db repeatedly in series to work without
    # flushing memcached or clearing the database manually.

    # With `zproject.test_settings`, we aren't using real memcached
    # and; we only need to flush memcached if we're populating a
    # database that would be used with it (i.e. zproject.dev_settings).
    if default_cache['BACKEND'] == 'django_pylibmc.memcached.PyLibMCCache':
        pylibmc.Client(
            [default_cache['LOCATION']],
            binary=True,
            username=default_cache["USERNAME"],
            password=default_cache["PASSWORD"],
            behaviors=default_cache["OPTIONS"],
        ).flush_all()

    model: Any = None  # Hack because mypy doesn't know these are model classes
    for model in [Message, Stream, UserProfile, Recipient,
                  Realm, Subscription, Huddle, UserMessage, Client,
                  DefaultStream]:
        model.objects.all().delete()
    Session.objects.all().delete()

# Suppress spammy output from the push notifications logger 
开发者ID:zulip,项目名称:zulip,代码行数:27,代码来源:populate_db.py

示例3: _imports

# 需要导入模块: import pylibmc [as 别名]
# 或者: from pylibmc import Client [as 别名]
def _imports(self):
        global bmemcached
        import bmemcached

        class RepairBMemcachedAPI(bmemcached.Client):
            """Repairs BMemcached's non-standard method
            signatures, which was fixed in BMemcached
            ef206ed4473fec3b639e.

            """

            def add(self, key, value):
                try:
                    return super(RepairBMemcachedAPI, self).add(key, value)
                except ValueError:
                    return False

        self.Client = RepairBMemcachedAPI 
开发者ID:caronc,项目名称:nzb-subliminal,代码行数:20,代码来源:memcached.py

示例4: _setup_bytecode_cache

# 需要导入模块: import pylibmc [as 别名]
# 或者: from pylibmc import Client [as 别名]
def _setup_bytecode_cache(cls):
        cache_type = config.get('jinja_bytecode_cache_type')
        bcc = None
        try:
            if cache_type == 'memcached' and config.get('memcached_host'):
                import pylibmc
                from jinja2 import MemcachedBytecodeCache
                client = pylibmc.Client([config['memcached_host']])
                bcc_prefix = 'jinja2/{}/'.format(jinja2.__version__)
                if six.PY3:
                    bcc_prefix += 'py{}{}/'.format(sys.version_info.major, sys.version_info.minor)
                bcc = MemcachedBytecodeCache(client, prefix=bcc_prefix)
            elif cache_type == 'filesystem':
                from jinja2 import FileSystemBytecodeCache
                bcc = FileSystemBytecodeCache(pattern='__jinja2_{}_%s.cache'.format(jinja2.__version__))
        except:
            log.exception("Error encountered while setting up a" +
                          " %s-backed bytecode cache for Jinja" % cache_type)
        return bcc 
开发者ID:apache,项目名称:allura,代码行数:21,代码来源:app_cfg.py

示例5: import_preferred_memcache_lib

# 需要导入模块: import pylibmc [as 别名]
# 或者: from pylibmc import Client [as 别名]
def import_preferred_memcache_lib(self, servers):
        """Returns an initialized memcache client.  Used by the constructor."""
        try:
            import pylibmc
        except ImportError:
            pass
        else:
            return pylibmc.Client(servers)

        try:
            from google.appengine.api import memcache
        except ImportError:
            pass
        else:
            return memcache.Client()

        try:
            import memcache
        except ImportError:
            pass
        else:
            return memcache.Client(servers)

        try:
            import libmc
        except ImportError:
            pass
        else:
            return libmc.Client(servers)


# backwards compatibility 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:34,代码来源:cache.py

示例6: import_preferred_memcache_lib

# 需要导入模块: import pylibmc [as 别名]
# 或者: from pylibmc import Client [as 别名]
def import_preferred_memcache_lib(self, servers):
        """Returns an initialized memcache client.  Used by the constructor."""
        try:
            import pylibmc
        except ImportError:
            pass
        else:
            return pylibmc.Client(servers)

        try:
            from google.appengine.api import memcache
        except ImportError:
            pass
        else:
            return memcache.Client()

        try:
            import memcache
        except ImportError:
            pass
        else:
            return memcache.Client(servers)

        try:
            import libmc
        except ImportError:
            pass
        else:
            return libmc.Client(servers) 
开发者ID:pallets,项目名称:cachelib,代码行数:31,代码来源:memcached.py

示例7: _setup

# 需要导入模块: import pylibmc [as 别名]
# 或者: from pylibmc import Client [as 别名]
def _setup(self, *args, **kw):
        super(MemcachedCacheHandler, self)._setup(*args, **kw)
        self._fix_hosts()
        self.mc = pylibmc.Client(self._config('hosts')) 
开发者ID:QData,项目名称:deepWordBug,代码行数:6,代码来源:ext_memcached.py

示例8: _create_client

# 需要导入模块: import pylibmc [as 别名]
# 或者: from pylibmc import Client [as 别名]
def _create_client(self):
        """Creation of a Client instance goes here."""
        raise NotImplementedError() 
开发者ID:caronc,项目名称:nzb-subliminal,代码行数:5,代码来源:memcached.py


注:本文中的pylibmc.Client方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。