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