本文整理汇总了Python中mc_bin_client.MemcachedClient.get方法的典型用法代码示例。如果您正苦于以下问题:Python MemcachedClient.get方法的具体用法?Python MemcachedClient.get怎么用?Python MemcachedClient.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mc_bin_client.MemcachedClient
的用法示例。
在下文中一共展示了MemcachedClient.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ComplianceTest
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import get [as 别名]
class ComplianceTest(unittest.TestCase):
def setUp(self):
self.mc=MemcachedClient()
self.mc.flush()
def tearDown(self):
self.mc.flush()
self.mc.close()
def testVersion(self):
"""Test the version command returns something."""
v=self.mc.version()
self.assertTrue(len(v) > 0, "Bad version: ``" + str(v) + "''")
def testSimpleSetGet(self):
"""Test a simple set and get."""
self.mc.set("x", 5, 19, "somevalue")
self.assertGet((19, "somevalue"), self.mc.get("x"))
def testZeroExpiration(self):
"""Ensure zero-expiration sets work properly."""
self.mc.set("x", 0, 19, "somevalue")
time.sleep(1.1)
self.assertGet((19, "somevalue"), self.mc.get("x"))
def assertNotExists(self, key):
try:
x=self.mc.get(key)
self.fail("Expected an exception, got " + `x`)
except MemcachedError, e:
self.assertEquals(memcacheConstants.ERR_NOT_FOUND, e.status)
示例2: test_vbucket_id_option
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import get [as 别名]
def test_vbucket_id_option(self):
bucket = RestConnection(self.server_origin).get_bucket(self.buckets[0])
self.num_items = self.num_items - (self.num_items % len(bucket.vbuckets))
num_items_per_vb = self.num_items / len(bucket.vbuckets)
template = '{{ "mutated" : 0, "age": {0}, "first_name": "{1}" }}'
gen_load = DocumentGenerator('cbtransfer', template, range(5), ['james', 'john'], start=0, end=self.num_items)
client = MemcachedClient(self.server_origin.ip,
int(bucket.vbuckets[0].master.split(':')[1]))
kv_value_dict = {}
vb_id_to_check = bucket.vbuckets[-1].id
for vb_id in xrange(len(bucket.vbuckets)):
cur_items_per_vb = 0
while cur_items_per_vb < num_items_per_vb:
key, value = gen_load.next()
client.set(key, 0, 0, value, vb_id)
if vb_id_to_check == vb_id:
kv_value_dict[key] = value
cur_items_per_vb += 1
transfer_source = 'http://%s:%s' % (self.server_origin.ip, self.server_origin.port)
transfer_destination = 'http://%s:%s' % (self.server_recovery.ip, self.server_recovery.port)
output = self.shell.execute_cbtransfer(transfer_source, transfer_destination,
"-b %s -B %s -i %s" % (bucket.name, bucket.name, vb_id_to_check))
client = MemcachedClient(self.server_recovery.ip,
int(bucket.vbuckets[0].master.split(':')[1]))
for key, value in kv_value_dict.iteritems():
_, _, d = client.get(key, vbucket=vb_id_to_check)
self.assertEquals(d, value, 'Key: %s expected. Value expected %s. Value actual %s' % (
key, value, d))
示例3: range
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import get [as 别名]
#for i in range(0,1023):
# mc.set_vbucket_state(i, 'active')
new_thread = TapListener(queue, server)
new_thread.start()
i = 0
while i < 4000:
for key in keys:
# vam.memcached(key).get(key)
mc.set(key, 10, 0, payload, vbucket=0)
# for key in keys:
# vam.memcached(key).get(key)
# mc.set(key, 1, 0, payload, vbucket=0)
try:
a,b,c = mc.get(key, vbucket=0)
# print c
except:
pass
i += 1
# print i
#for key in keys:
# vam.memcached(key).get(key)
# mc.set(key, 1, 0, payload, vbucket=0)
# mc.get(key, vbucket=0)
#for key in keys:
# vam.memcached(key).get(key)
示例4: str
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import get [as 别名]
prefix = str(uuid.uuid4())
number_of_items = int(options.items)
mc = MemcachedClient("127.0.0.1", 11211)
keys = ["{0}-{1}".format(prefix, i) for i in range(0, number_of_items)]
info("inserting {0} items".format(number_of_items))
for k in keys:
mc.set(k, 0, 0, str(uuid.uuid4())[0:16])
while True:
info("now remove 3 chars from 80% of keys - if < 3 chars delete the key - if key does not exist create it")
for i in range(0, 3):
for k in keys:
try:
a, b, value = mc.get(k)
if len(value) < 3:
mc.delete(k)
else:
mc.set(k, 0, 0, value[0:len(value) - 7])
except:
mc.set(k, 0, 0, str(uuid.uuid4())[0:16])
time.sleep(sleep_time)
for k in keys:
try:
mc.prepend(k, "two")
except:
mc.set(k, 0, 0, str(uuid.uuid4())[0:16])
time.sleep(sleep_time)