本文整理汇总了Python中libmc.Client.decr方法的典型用法代码示例。如果您正苦于以下问题:Python Client.decr方法的具体用法?Python Client.decr怎么用?Python Client.decr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libmc.Client
的用法示例。
在下文中一共展示了Client.decr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CmemcachedRegressionCase
# 需要导入模块: from libmc import Client [as 别名]
# 或者: from libmc.Client import decr [as 别名]
#.........这里部分代码省略.........
self.mc.set(key, b"")
self.assertEqual(self.mc.append(key, value), True)
self.assertEqual(self.mc.append(key, value), True)
self.assertEqual(self.mc.prepend(key, b'before\n'), True)
self.assertEqual(self.mc.get(key), b'before\n' + value * 2)
def test_set_multi(self):
values = dict(('key%s' % k, ('value%s' % k) * 100)
for k in range(1000))
values.update({' ': ''})
self.assertEqual(self.mc.set_multi(values), False)
del values[' ']
self.assertEqual(self.mc.get_multi(list(values.keys())), values)
def test_append_large(self):
k = 'test_append_large'
self.mc.set(k, b'a' * 2048)
self.mc.append(k, b'bbbb')
assert b'bbbb' not in self.mc.get(k)
self.mc.set(k, b'a' * 2048, compress=False)
self.mc.append(k, b'bbbb')
assert b'bbbb' in self.mc.get(k)
def test_incr(self):
key = "Not_Exist"
self.assertEqual(self.mc.incr(key), None)
# key="incr:key1"
# self.mc.set(key, "not_numerical")
# self.assertEqual(self.mc.incr(key), 0)
key = "incr:key2"
self.mc.set(key, 2007)
self.assertEqual(self.mc.incr(key), 2008)
def test_decr(self):
key = "Not_Exist"
self.assertEqual(self.mc.decr(key), None)
# key="decr:key1"
# self.mc.set(key, "not_numerical")
# self.assertEqual(self.mc.decr(key),0)
key = "decr:key2"
self.mc.set(key, 2009)
self.assertEqual(self.mc.decr(key), 2008)
def test_get_multi(self):
keys = ["hello1", "hello2", "hello3"]
values = ["vhello1", "vhello2", "vhello3"]
for x in range(3):
self.mc.set(keys[x], values[x])
self.assertEqual(self.mc.get(keys[x]), values[x])
result = self.mc.get_multi(keys)
for x in range(3):
self.assertEqual(result[keys[x]], values[x])
def test_get_multi_invalid(self):
keys = ["hello1", "hello2", "hello3"]
values = ["vhello1", "vhello2", "vhello3"]
for x in range(3):
self.mc.set(keys[x], values[x])
self.assertEqual(self.mc.get(keys[x]), values[x])
invalid_keys = keys + ['hoho\r\n']
result = self.mc.get_multi(invalid_keys)
for x in range(3):
self.assertEqual(result[keys[x]], values[x])
result_new = self.mc.get_multi(keys)
for x in range(3):
self.assertEqual(result_new[keys[x]], values[x])