本文整理汇总了Python中umemcache.Client类的典型用法代码示例。如果您正苦于以下问题:Python Client类的具体用法?Python Client怎么用?Python Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testStats
def testStats(self):
c = Client(MEMCACHED_ADDRESS);
c.connect();
d = c.stats()
self.assertTrue (d.has_key("uptime"))
self.assertTrue (d.has_key("bytes"))
开发者ID:noonat,项目名称:ultramemcache,代码行数:7,代码来源:tests.py
示例2: testVersion
def testVersion(self):
c = Client(MEMCACHED_ADDRESS);
c.connect();
v = c.version()
l = v.split('.');
self.assertEquals(3, len(l))
开发者ID:noonat,项目名称:ultramemcache,代码行数:7,代码来源:tests.py
示例3: testTupleRefCrashFix
def testTupleRefCrashFix(self):
client = Client(MEMCACHED_ADDRESS)
for i in range(1000):
try:
client.connect()
except:
pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:7,代码来源:tests.py
示例4: testCas
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,代码行数:8,代码来源:tests.py
示例5: _create_connector
def _create_connector(self):
if self.max_item_size is not None:
self._client = OriginalClient(self.address, self.max_item_size)
else:
self._client = OriginalClient(self.address)
self.funcs = [func for func in dir(self._client)
if not func.startswith('_')]
开发者ID:wrongwaycn,项目名称:django-memcached-pool,代码行数:8,代码来源:client.py
示例6: testOversizedKey
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,代码行数:9,代码来源:tests.py
示例7: testConnectFails
def testConnectFails(self):
c = Client("130.244.1.1:31337");
try:
c.connect();
assert False
except:
pass
c.disconnect();
pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:10,代码来源:tests.py
示例8: testConnectDNSFails
def testConnectDNSFails(self):
c = Client("flensost:12111");
try:
c.connect();
assert False
except:
pass
c.disconnect();
pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:10,代码来源:tests.py
示例9: testFlushAll
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,代码行数:7,代码来源:tests.py
示例10: testConnectFails
def testConnectFails(self):
c = Client("130.244.1.1:31337");
c.sock.settimeout(2)
try:
c.connect();
assert False
except:
pass
c.disconnect();
pass
开发者ID:nanonyme,项目名称:ultramemcache,代码行数:11,代码来源:tests.py
示例11: testPipelineDoesNotAllowReads
def testPipelineDoesNotAllowReads(self):
c = Client(MEMCACHED_ADDRESS)
c.connect()
c.begin_pipeline()
self.assertRaises(MemcachedError, c.get, "foo")
self.assertRaises(MemcachedError, c.gets, "foo")
self.assertRaises(MemcachedError, c.get_multi, ["foo"])
self.assertRaises(MemcachedError, c.gets_multi, ["foo"])
self.assertRaises(MemcachedError, c.version)
self.assertRaises(MemcachedError, c.stats)
开发者ID:nanonyme,项目名称:ultramemcache,代码行数:12,代码来源:tests.py
示例12: Client
class Client(object):
"""On connection errors, tries to reconnect
"""
def __init__(self, address, max_item_size=None, max_connect_retries=5,
reconnect_delay=.5):
self.address = address
self.max_item_size = max_item_size
self._client = None
self.funcs = []
self._create_client()
self.max_connect_retries = max_connect_retries
self.reconnect_delay = reconnect_delay
def _create_connector(self):
if self.max_item_size is not None:
self._client = OriginalClient(self.address, self.max_item_size)
else:
self._client = OriginalClient(self.address)
self.funcs = [func for func in dir(self._client)
if not func.startswith('_')]
def _create_client(self):
reconnect = self._client is not None
if reconnect:
try:
self._client.close()
except Exception:
pass
self._create_connector()
if reconnect:
retries = 0
delay = self.reconnect_delay
while retries < self.max_connect_retries:
try:
self._client.connect()
except socket.error, exc:
if exc.errno == EISCONN:
return # we're good
if exc.errno == EINVAL:
# we're doomed, retry
self._create_connector()
time.sleep(delay)
retries += 1
delay *= 2 # growing the delay
raise exc
开发者ID:wrongwaycn,项目名称:django-memcached-pool,代码行数:51,代码来源:client.py
示例13: testDel
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,代码行数:7,代码来源:tests.py
示例14: testGets
def testGets(self):
c = Client(MEMCACHED_ADDRESS);
c.connect();
c.set("key", "value")
self.assertEquals("value", c.gets("key")[0])
self.assertEquals(None, c.gets("key23123"))
r = c.gets("key")
self.assertEquals(3, len(r))
pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:9,代码来源:tests.py
示例15: testAppend
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,代码行数:7,代码来源:tests.py
示例16: testPrepend
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,代码行数:7,代码来源:tests.py
示例17: testConnectTwice
def testConnectTwice(self):
c = Client(MEMCACHED_ADDRESS);
c.connect();
c.disconnect();
self.assertEquals(False, c.is_connected());
try:
c.connect();
assert False
except (RuntimeError):
pass
pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:13,代码来源:tests.py
示例18: testGet_multi
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,代码行数:14,代码来源:tests.py
示例19: testReplace
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,代码行数:8,代码来源:tests.py
示例20: testBigDataFail
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,代码行数:8,代码来源:tests.py
注:本文中的umemcache.Client类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论