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


Python Client.gets_multi方法代码示例

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


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

示例1: testCasGetsMulti

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import gets_multi [as 别名]
 def testCasGetsMulti(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "a")
     c.set("key2", "a")
     results = c.gets_multi(("key1", "key2"))
     cas1 = results["key1"][2]
     cas2 = results["key2"][2]
     self.assertEquals("STORED", c.cas("key1", "b", cas1))
     self.assertEquals("STORED", c.cas("key2", "b", cas2))
     results = c.gets_multi(("key1", "key2"))
     cas1 = results["key1"][2]
     cas2 = results["key2"][2]
     c.set("key1", "a")
     self.assertEquals("EXISTS", c.cas("key1", "b", cas1))
     self.assertEquals("STORED", c.cas("key2", "b", cas2))
开发者ID:nanonyme,项目名称:ultramemcache,代码行数:18,代码来源:tests.py

示例2: testGets_multi

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import gets_multi [as 别名]
    def testGets_multi(self):
        c = Client(MEMCACHED_ADDRESS);
        c.connect();
        c.set("key1", "value1")
        c.set("key2", "value2")
        c.set("key3", "value3")
        r = c.gets_multi(["key1", "key2", "key3", "key4"])

        self.assertEquals(3, len(r["key1"]))
        self.assertEquals(3, len(r["key2"]))
        self.assertEquals(3, len(r["key3"]))

        self.assertEquals("value1", r["key1"][0])
        self.assertEquals("value2", r["key2"][0])
        self.assertEquals("value3", r["key3"][0])
        self.assertEquals(None, r.get("key4"))
        pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:19,代码来源:tests.py

示例3: testPipeline

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

#.........这里部分代码省略.........
        c2.add("added4", "rab")
        self.assertEquals("foo", c1.get("added1")[0])
        self.assertEquals("bar", c1.get("added2")[0])
        self.assertEquals(None, c1.get("added3"))
        self.assertEquals(None, c1.get("added4"))
        res = c2.finish_pipeline()
        self.assertEquals(["NOT_STORED", "NOT_STORED", "STORED", "STORED"], res)
        self.assertEquals("foo", c1.get("added1")[0])
        self.assertEquals("bar", c1.get("added2")[0])
        self.assertEquals("oof", c1.get("added3")[0])
        self.assertEquals("rab", c1.get("added4")[0])

        # Replace
        c1.set("replace1", "foo")
        c1.set("replace2", "bar")
        self.assertEquals("foo", c1.get("replace1")[0])
        self.assertEquals("bar", c1.get("replace2")[0])
        c2.begin_pipeline()
        c2.replace("replace1", "bim")
        c2.replace("replace2", "baz")
        c2.replace("replace3", "oof")
        c2.replace("replace4", "rab")
        self.assertEquals("foo", c1.get("replace1")[0])
        self.assertEquals("bar", c1.get("replace2")[0])
        self.assertEquals(None, c1.get("replace3"))
        self.assertEquals(None, c1.get("replace4"))
        res = c2.finish_pipeline()
        self.assertEquals(["STORED", "STORED", "NOT_STORED", "NOT_STORED"], res)
        self.assertEquals("bim", c1.get("replace1")[0])
        self.assertEquals("baz", c1.get("replace2")[0])
        self.assertEquals(None, c1.get("replace3"))
        self.assertEquals(None, c1.get("replace4"))

        # Append / Prepend
        c1.set("append1", "a,")
        self.assertEquals("a,", c1.get("append1")[0])
        c2.begin_pipeline()
        c2.append("append1", "b,")
        c2.append("append1", "c,")
        c2.append("append1", "d,")
        c2.prepend("append1", "x,")
        c2.prepend("append1", "y,")
        c2.prepend("append1", "z,")
        self.assertEquals("a,", c1.get("append1")[0])
        res = c2.finish_pipeline()
        self.assertEquals(["STORED"] * 6, res)
        self.assertEquals("z,y,x,a,b,c,d,", c1.get("append1")[0])

        # Delete
        c1.set("delete1", "foo")
        c1.set("delete2", "bar")
        self.assertEquals("foo", c1.get("delete1")[0])
        self.assertEquals("bar", c1.get("delete2")[0])
        self.assertEquals(None, c1.get("delete3"))
        c2.begin_pipeline()
        c2.delete("delete1")
        c2.delete("delete2")
        c2.delete("delete3")
        self.assertEquals("foo", c1.get("delete1")[0])
        self.assertEquals("bar", c1.get("delete2")[0])
        self.assertEquals(None, c1.get("delete3"))
        res = c2.finish_pipeline()
        self.assertEquals(["DELETED", "DELETED", "NOT_FOUND"], res)
        self.assertEquals(None, c1.get("delete1"))
        self.assertEquals(None, c1.get("delete2"))
        self.assertEquals(None, c1.get("delete3"))

        # CAS
        c1.set("cas1", "foo")
        c1.set("cas2", "bar")
        c1.set("cas3", "bim")
        gots = c1.gets_multi(["cas1", "cas2", "cas3"])
        self.assertEquals("foo", gots["cas1"][0])
        self.assertEquals("bar", gots["cas2"][0])
        self.assertEquals("bim", gots["cas3"][0])
        c1.set("cas1", "baz")
        c2.begin_pipeline()
        c2.cas("cas1", "betty", gots["cas1"][2])
        c2.cas("cas2", "wilma", gots["cas2"][2])
        c2.cas("cas3", "fred", gots["cas3"][2])
        self.assertEquals("baz", c1.get("cas1")[0])
        self.assertEquals("bar", c1.get("cas2")[0])
        self.assertEquals("bim", c1.get("cas3")[0])
        res = c2.finish_pipeline()
        self.assertEquals(["EXISTS", "STORED", "STORED"], res)
        gots = c1.gets_multi(["cas1", "cas2", "cas3"])
        self.assertEquals("baz", c1.get("cas1")[0])
        self.assertEquals("wilma", c1.get("cas2")[0])
        self.assertEquals("fred", c1.get("cas3")[0])

        # Flush All
        c1.set("flush1", "foo")
        c1.set("flush2", "bar")
        c2.begin_pipeline()
        c2.flush_all()
        self.assertEquals("foo", c1.get("flush1")[0])
        self.assertEquals("bar", c1.get("flush2")[0])
        c2.finish_pipeline()
        self.assertEquals(None, c1.get("flush1"))
        self.assertEquals(None, c1.get("flush2"))
开发者ID:nanonyme,项目名称:ultramemcache,代码行数:104,代码来源:tests.py


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