本文整理匯總了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])