当前位置: 首页>>代码示例>>Python>>正文


Python Client.set_multi方法代码示例

本文整理汇总了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
开发者ID:txdywy,项目名称:libmc,代码行数:10,代码来源:infinite_set_get.py

示例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
开发者ID:601186678,项目名称:libmc,代码行数:12,代码来源:infinite_set_get.py

示例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)
开发者ID:douban,项目名称:libmc,代码行数:70,代码来源:test_cmemcached_regression.py


注:本文中的libmc.Client.set_multi方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。