本文整理汇总了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
示例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
示例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)
示例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
示例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
示例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))
示例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)
示例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
示例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")
示例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
示例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))
示例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
示例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
示例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))
示例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)