本文整理汇总了Python中couchbase.bucket.Bucket.insert_multi方法的典型用法代码示例。如果您正苦于以下问题:Python Bucket.insert_multi方法的具体用法?Python Bucket.insert_multi怎么用?Python Bucket.insert_multi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类couchbase.bucket.Bucket
的用法示例。
在下文中一共展示了Bucket.insert_multi方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SDKClient
# 需要导入模块: from couchbase.bucket import Bucket [as 别名]
# 或者: from couchbase.bucket.Bucket import insert_multi [as 别名]
#.........这里部分代码省略.........
def upsert(self, key, value, cas=0, ttl=0, format=None, persist_to=0, replicate_to=0):
try:
self.cb.upsert(key, value, cas, ttl, format, persist_to, replicate_to)
except CouchbaseError as e:
try:
time.sleep(10)
self.cb.upsert(key, value, cas, ttl, format, persist_to, replicate_to)
except CouchbaseError as e:
raise
def set_multi(self, keys, ttl=0, format=None, persist_to=0, replicate_to=0):
return self.upsert_multi(keys, ttl=ttl, format=format, persist_to=persist_to, replicate_to=replicate_to)
def upsert_multi(self, keys, ttl=0, format=None, persist_to=0, replicate_to=0):
try:
self.cb.upsert_multi(keys, ttl=ttl, format=format, persist_to=persist_to, replicate_to=replicate_to)
except CouchbaseError as e:
try:
time.sleep(10)
self.cb.upsert_multi(keys, ttl=ttl, format=format, persist_to=persist_to, replicate_to=replicate_to)
except CouchbaseError as e:
raise
def insert(self, key, value, ttl=0, format=None, persist_to=0, replicate_to=0):
try:
self.cb.insert(key, value, ttl=ttl, format=format, persist_to=persist_to, replicate_to=replicate_to)
except CouchbaseError as e:
try:
time.sleep(10)
self.cb.insert(key, value, ttl=ttl, format=format, persist_to=persist_to, replicate_to=replicate_to)
except CouchbaseError as e:
raise
def insert_multi(self, keys, ttl=0, format=None, persist_to=0, replicate_to=0):
try:
self.cb.insert_multi(keys, ttl=ttl, format=format, persist_to=persist_to, replicate_to=replicate_to)
except CouchbaseError as e:
try:
time.sleep(10)
self.cb.insert_multi(keys, ttl=ttl, format=format, persist_to=persist_to, replicate_to=replicate_to)
except CouchbaseError as e:
raise
def touch(self, key, ttl = 0):
try:
self.cb.touch(key, ttl=ttl)
except CouchbaseError as e:
try:
time.sleep(10)
self.cb.touch(key, ttl=ttl)
except CouchbaseError as e:
raise
def touch_multi(self, keys, ttl = 0):
try:
self.cb.touch_multi(keys, ttl=ttl)
except CouchbaseError as e:
try:
time.sleep(10)
self.cb.touch_multi(keys, ttl=ttl)
except CouchbaseError as e:
raise
def decr(self, key, delta=1, initial=None, ttl=0):
self.counter(key, delta=-delta, initial=initial, ttl=ttl)
示例2: Bucket
# 需要导入模块: from couchbase.bucket import Bucket [as 别名]
# 或者: from couchbase.bucket.Bucket import insert_multi [as 别名]
from couchbase.bucket import Bucket
bucket = Bucket("couchbase://localhost/retail")
f = open('retail.txt','r')
count = 1
inserts = dict()
for line in f:
items = map(int, line.strip().split(" "))
inserts["order::%d" % count] = {'type': 'order', 'items': items}
count += 1
bucket.insert_multi(inserts)