當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。