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


Python Client.set方法代码示例

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


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

示例1: testGet

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
 def testGet(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key", "value")
     self.assertEquals("value", c.get("key")[0])
     self.assertEquals(None, c.get("key23123"))
     pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:9,代码来源:tests.py

示例2: testDel

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
 def testDel(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key1", "a")
     c.delete("key1")
     self.assertEquals(None, c.get("key1"))
     pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:9,代码来源:tests.py

示例3: testFlushAll

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
 def testFlushAll(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key1", "31337")
     self.assertEquals(c.get("key1")[0], "31337")
     c.flush_all()
     self.assertEquals(c.get("key1"), None)
开发者ID:noonat,项目名称:ultramemcache,代码行数:9,代码来源:tests.py

示例4: testAppend

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
 def testAppend(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "a")
     self.assertEquals("STORED", c.append("key1", "b"))
     self.assertEquals("ab", c.get("key1")[0])
     pass
开发者ID:rfk,项目名称:ultramemcache,代码行数:9,代码来源:tests.py

示例5: testPrepend

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
 def testPrepend(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key1", "a")
     self.assertEquals("STORED", c.prepend("key1", "b"))
     self.assertEquals("ba", c.get("key1")[0])
     pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:9,代码来源:tests.py

示例6: testCas

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
 def testCas(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key1", "a")
     value, flags, cas = c.gets("key1")
     self.assertEquals("STORED", c.cas("key1", "b", cas))
     c.set("key1", "a")
     self.assertEquals("EXISTS", c.cas("key1", "b", cas))
开发者ID:noonat,项目名称:ultramemcache,代码行数:10,代码来源:tests.py

示例7: testBigDataFail

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
    def testBigDataFail(self):
    	c = Client(MEMCACHED_ADDRESS);
        c.connect();
        data = "31337" * 10000

        for x in xrange(0, 10):
            v = c.get("kaka" + str(x))
            c.set("fsdafbdsakjfjdkfjadklsafdsafdsaffdsafdasfdsafdasfsdafdsafdsafasdas" + str(x), data, 604830, 17, True)
开发者ID:noonat,项目名称:ultramemcache,代码行数:10,代码来源:tests.py

示例8: testReplace

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
    def testReplace(self):
        c = Client(MEMCACHED_ADDRESS);
        c.connect();
        c.set("key1", "value1")
        self.assertEquals("STORED", c.replace("key1", "value"))
        pass

        pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:10,代码来源:tests.py

示例9: testSockAccess

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
 def testSockAccess(self):
     # accessing the members before connect() is called
     c = Client(MEMCACHED_ADDRESS)
     self.assertEquals(c.host, MEMCACHED_HOST)
     self.assertEquals(c.port, MEMCACHED_PORT)
     self.assertTrue(isinstance(c.sock, socket.socket))
     c.sock.settimeout(2)
     c.connect()
     c.set("key1", "31337")
     self.assertEquals(c.get("key1")[0], "31337")
开发者ID:noonat,项目名称:ultramemcache,代码行数:12,代码来源:tests.py

示例10: testGet_multi

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

        self.assertEquals(("value1", 0), r["key1"])
        self.assertEquals(("value2", 0), r["key2"])
        self.assertEquals(("value3", 0), r["key3"])
        self.assertEquals(None, r.get("key4"))

        pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:16,代码来源:tests.py

示例11: testCasGetsMulti

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [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

示例12: testOversizedKey

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
 def testOversizedKey(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     data = "A" * (1000 * 1000 * 2)
     try:
         r = c.set("test", data)
         assert False
     except(RuntimeError):
         pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:11,代码来源:tests.py

示例13: testConnectCloseQuery

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
 def testConnectCloseQuery(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.disconnect();
     try:
         r = c.set("jonas", "kaka", 0, False)
         assert False
     except:
         pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:11,代码来源:tests.py

示例14: testRandomData

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
    def testRandomData(self):
        def random_bytes(size):
            return "".join(chr(random.randrange(0, 256)) for i in xrange(size))

        def random_str(size):
            return "".join(chr(random.randrange(33, 64)) for i in xrange(size))

        c = Client(MEMCACHED_ADDRESS)
        c.connect()

        count = 0

        for x in xrange(0, 10):
            key = random_str(random.randrange(1, 33))
            value = random_bytes(random.randrange(1, 5000))
            c.set(key, value, 0, 0, True)
            v2 = c.get(key)[0]

            count += 1

            if len(value) != len(v2):
                print "%d %d != %d" % (count, len(value), len(v2))
开发者ID:rfk,项目名称:ultramemcache,代码行数:24,代码来源:tests.py

示例15: testIncrDecrString

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import set [as 别名]
 def testIncrDecrString(self):
 	c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("test", "hej")
 	self.assertRaises(Exception, c.incr, "test", 1)
 	self.assertRaises(Exception, c.decr, "test", 5)
开发者ID:noonat,项目名称:ultramemcache,代码行数:8,代码来源:tests.py


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