本文整理汇总了Python中libmc.Client.set_multi方法的典型用法代码示例。如果您正苦于以下问题:Python Client.set_multi方法的具体用法?Python Client.set_multi怎么用?Python Client.set_multi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libmc.Client
的用法示例。
在下文中一共展示了Client.set_multi方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from libmc import Client [as 别名]
# 或者: from libmc.Client import set_multi [as 别名]
def main():
mc = Client(["127.0.0.1:%d" % (21211 + i) for i in range(10)])
dct = {"test_key_%d" % i: "i" * 1000 for i in range(10)}
while True:
print "%.2f: set_multi: %r" % (time.time(), mc.set_multi(dct))
print "%.2f: get_multi: %r" % (time.time(), mc.get_multi(dct.keys()) == dct)
time.sleep(0.5)
print
示例2: main
# 需要导入模块: from libmc import Client [as 别名]
# 或者: from libmc.Client import set_multi [as 别名]
def main():
mc = Client(['127.0.0.1:%d' % (21211 + i) for i in range(10)])
dct = {'test_key_%d' % i: 'i' * 1000 for i in range(10)}
while True:
print '%.2f: set_multi: %r' % (time.time(), mc.set_multi(dct))
print '%.2f: get_multi: %r' % (
time.time(), mc.get_multi(dct.keys()) == dct
)
time.sleep(0.5)
print
示例3: CmemcachedRegressionCase
# 需要导入模块: from libmc import Client [as 别名]
# 或者: from libmc.Client import set_multi [as 别名]
#.........这里部分代码省略.........
self.assertEqual(self.mc.set(key1, value), True)
self.assertEqual(self.mc.get(bytes_key1), self.mc.get(key1))
self.assertEqual(self.mc.get(bytes_key2), self.mc.get(key2))
def test_add(self):
key = 'test_add'
self.mc.delete(key)
self.assertEqual(self.mc.add(key, 'tt'), True)
self.assertEqual(self.mc.get(key), 'tt')
self.assertEqual(self.mc.add(key, 'tt'), 0)
self.mc.delete(key + '2')
self.assertEqual(self.mc.add(key + '2', range(10)), True)
def test_replace(self):
key = 'test_replace'
self.mc.delete(key)
self.assertEqual(self.mc.replace(key, ''), 0)
self.assertEqual(self.mc.set(key, 'b'), True)
self.assertEqual(self.mc.replace(key, 'a'), True)
self.assertEqual(self.mc.get(key), 'a')
def test_append(self):
key = "test_append"
value = b"append\n"
self.mc.delete(key)
self.assertEqual(self.mc.append(key, value), 0)
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)