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


Python Client.append_multi方法代码示例

本文整理汇总了Python中libmc.Client.append_multi方法的典型用法代码示例。如果您正苦于以下问题:Python Client.append_multi方法的具体用法?Python Client.append_multi怎么用?Python Client.append_multi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libmc.Client的用法示例。


在下文中一共展示了Client.append_multi方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CmemcachedRegressionCase

# 需要导入模块: from libmc import Client [as 别名]
# 或者: from libmc.Client import append_multi [as 别名]

#.........这里部分代码省略.........
        self.assertEqual(self.server_addr in s, True)
        st = s[self.server_addr]
        st_keys = {
            "pid",
            "uptime",
            "time",
            "version",
            "pointer_size",
            "rusage_user",
            "rusage_system",
            "curr_items",
            "total_items",
            "bytes",
            "curr_connections",
            "total_connections",
            "connection_structures",
            "cmd_get",
            "cmd_set",
            "get_hits",
            "get_misses",
            "evictions",
            "bytes_read",
            "bytes_written",
            "limit_maxbytes",
            "threads",
        }
        self.assertTrue(set(st.keys()) >= st_keys)
        ''' TODO
        mc = cmemcached.Client([INVALID_SERVER_ADDR, self.server_addr])
        s = mc.stats()
        self.assertEqual(len(s), 2)
        '''

    def test_append_multi(self):
        N = 10
        K = "test_append_multi_%d"
        data = b"after\n"
        for i in range(N):
            self.assertEqual(self.mc.set(K % i, b"before\n"), True)
        keys = [K % i for i in range(N)]
        # append
        self.assertEqual(self.mc.append_multi(keys, data), True)
        self.assertEqual(self.mc.get_multi(keys),
                         dict(zip(keys, [b"before\n" + data] * N)))
        # prepend
        self.assertEqual(self.mc.prepend_multi(keys, data), True)
        self.assertEqual(self.mc.get_multi(keys),
                         dict(zip(keys, [data + b"before\n" + data] * N)))
        # delete
        self.assertEqual(self.mc.delete_multi(keys), True)
        self.assertEqual(self.mc.get_multi(keys), {})

    def test_append_multi_performance(self):
        N = 70000
        K = "test_append_multi_%d"
        data = b"after\n"
        keys = [K % i for i in range(N)]
        t = time.time()
        self.mc.append_multi(keys, data)
        t = time.time() - t
        threshold = 5
        assert t < threshold, 'should append 7w key in %s secs, ' \
                              'actual val: %f' % (threshold, t)

    def test_get_host(self):
        host = self.mc.get_host_by_key("str")
开发者ID:douban,项目名称:libmc,代码行数:70,代码来源:test_cmemcached_regression.py


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