本文整理汇总了Python中pymemcache.client.base.Client.flush_all方法的典型用法代码示例。如果您正苦于以下问题:Python Client.flush_all方法的具体用法?Python Client.flush_all怎么用?Python Client.flush_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymemcache.client.base.Client
的用法示例。
在下文中一共展示了Client.flush_all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_incr_decr
# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import flush_all [as 别名]
def test_incr_decr(client_class, host, port, socket_module):
client = Client((host, port), socket_module=socket_module)
client.flush_all()
result = client.incr(b'key', 1, noreply=False)
assert result is None
result = client.set(b'key', b'0', noreply=False)
assert result is True
result = client.incr(b'key', 1, noreply=False)
assert result == 1
def _bad_int():
client.incr(b'key', b'foobar')
with pytest.raises(MemcacheClientError):
_bad_int()
result = client.decr(b'key1', 1, noreply=False)
assert result is None
result = client.decr(b'key', 1, noreply=False)
assert result == 0
result = client.get(b'key')
assert result == b'0'
示例2: test_serialization_deserialization
# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import flush_all [as 别名]
def test_serialization_deserialization(host, port, socket_module):
def _ser(key, value):
return json.dumps(value).encode('ascii'), 1
def _des(key, value, flags):
if flags == 1:
return json.loads(value.decode('ascii'))
return value
client = Client((host, port), serializer=_ser, deserializer=_des,
socket_module=socket_module)
client.flush_all()
value = {'a': 'b', 'c': ['d']}
client.set(b'key', value)
result = client.get(b'key')
assert result == value
示例3: test_misc
# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import flush_all [as 别名]
def test_misc(client_class, host, port, socket_module):
client = Client((host, port), socket_module=socket_module)
client.flush_all()
示例4: memcached
# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import flush_all [as 别名]
def memcached(self, host, port):
memcached = Client((host, port))
yield memcached
memcached.flush_all()