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


Python pylibmc.NotFound方法代碼示例

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


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

示例1: incr

# 需要導入模塊: import pylibmc [as 別名]
# 或者: from pylibmc import NotFound [as 別名]
def incr(self, key, delta=1, version=None):
        key = self.make_key(key, version=version)
        # memcached doesn't support a negative delta
        if delta < 0:
            return self._cache.decr(key, -delta)
        try:
            val = self._cache.incr(key, delta)

        # python-memcache responds to incr on non-existent keys by
        # raising a ValueError, pylibmc by raising a pylibmc.NotFound
        # and Cmemcache returns None. In all cases,
        # we should raise a ValueError though.
        except self.LibraryValueNotFoundException:
            val = None
        if val is None:
            raise ValueError("Key '%s' not found" % key)
        return val 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:19,代碼來源:memcached.py

示例2: decr

# 需要導入模塊: import pylibmc [as 別名]
# 或者: from pylibmc import NotFound [as 別名]
def decr(self, key, delta=1, version=None):
        key = self.make_key(key, version=version)
        # memcached doesn't support a negative delta
        if delta < 0:
            return self._cache.incr(key, -delta)
        try:
            val = self._cache.decr(key, delta)

        # python-memcache responds to incr on non-existent keys by
        # raising a ValueError, pylibmc by raising a pylibmc.NotFound
        # and Cmemcache returns None. In all cases,
        # we should raise a ValueError though.
        except self.LibraryValueNotFoundException:
            val = None
        if val is None:
            raise ValueError("Key '%s' not found" % key)
        return val 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:19,代碼來源:memcached.py

示例3: _cache

# 需要導入模塊: import pylibmc [as 別名]
# 或者: from pylibmc import NotFound [as 別名]
def _cache(self, key, data):
        current_lock = self._lock_value()
        with self.client_pool.reserve() as client:
            while True:
                value, cid = client.gets(key)
                # If there is a lock value in Memcache that is
                # different from our own we have to bail.
                if value and value.startswith(self._lock_prefix) and value != current_lock:
                    return

                # If there isn't a value at all, we have to add one
                # and try again.
                if cid is None:
                    client.add(key, current_lock, self._lock_timeout)
                    continue

                try:
                    return client.cas(key, data, cid, self._item_timeout)

                # There is a small chance that between the `gets` and
                # "now" the key will have been deleted by a concurrent
                # process, so we account for that possibility here.
                except pylibmc.NotFound:  # pragma: no cover
                    return 
開發者ID:Bogdanp,項目名稱:anom-py,代碼行數:26,代碼來源:memcache_adapter.py

示例4: __init__

# 需要導入模塊: import pylibmc [as 別名]
# 或者: from pylibmc import NotFound [as 別名]
def __init__(self, server, params, library, value_not_found_exception):
        super(BaseMemcachedCache, self).__init__(params)
        if isinstance(server, six.string_types):
            self._servers = server.split(';')
        else:
            self._servers = server

        # The exception type to catch from the underlying library for a key
        # that was not found. This is a ValueError for python-memcache,
        # pylibmc.NotFound for pylibmc, and cmemcache will return None without
        # raising an exception.
        self.LibraryValueNotFoundException = value_not_found_exception

        self._lib = library
        self._options = params.get('OPTIONS', None) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:17,代碼來源:memcached.py

示例5: __init__

# 需要導入模塊: import pylibmc [as 別名]
# 或者: from pylibmc import NotFound [as 別名]
def __init__(self, server, params, library, value_not_found_exception):
        super(BaseMemcachedCache, self).__init__(params)
        if isinstance(server, string_types):
            self._servers = server.split(';')
        else:
            self._servers = server

        # The exception type to catch from the underlying library for a key
        # that was not found. This is a ValueError for python-memcache,
        # pylibmc.NotFound for pylibmc, and cmemcache will return None without
        # raising an exception.
        self.LibraryValueNotFoundException = value_not_found_exception

        self._lib = library
        self._options = params.get('OPTIONS', None) 
開發者ID:mqingyn,項目名稱:torngas,代碼行數:17,代碼來源:memcached.py

示例6: __init__

# 需要導入模塊: import pylibmc [as 別名]
# 或者: from pylibmc import NotFound [as 別名]
def __init__(self, server, params):
        import pylibmc

        self._local = local()
        #pylibmc.NotFound需更改為None,否則在本地會出現錯誤,模擬的sae.memcache中沒有NotFound屬性
        super(SaePyLibMCCache, self).__init__(server, params, library=pylibmc, value_not_found_exception=None) 
開發者ID:smallcode,項目名稱:django-sae,代碼行數:8,代碼來源:backends.py


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