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


Python Bucket.mutate_in方法代码示例

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


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

示例1: test_eventing_does_not_use_xattrs

# 需要导入模块: from couchbase.bucket import Bucket [as 别名]
# 或者: from couchbase.bucket.Bucket import mutate_in [as 别名]
 def test_eventing_does_not_use_xattrs(self):
     body = self.create_save_function_body(self.function_name, HANDLER_CODE.BUCKET_OPS_WITH_TIMERS,
                                           dcp_stream_boundary="from_now")
     # deploy eventing function
     self.deploy_function(body)
     url = 'couchbase://{ip}/{name}'.format(ip=self.master.ip, name=self.src_bucket_name)
     bucket = Bucket(url, username="cbadminbucket", password="password")
     for docid in ['customer123', 'customer1234', 'customer12345']:
         bucket.upsert(docid, {'a': 1})
     self.verify_eventing_results(self.function_name, 3, skip_stats_validation=True)
     # add new multiple xattrs , delete old xattrs and delete the documents
     for docid in ['customer123', 'customer1234', 'customer12345']:
         r = bucket.mutate_in(docid, SD.get('eventing', xattr=True))
         log.info(r)
         if "Could not execute one or more multi lookups or mutations" not in str(r):
             self.fail("eventing is still using xattrs for timers")
         r = bucket.mutate_in(docid, SD.get('_eventing', xattr=True))
         log.info(r)
         if "Could not execute one or more multi lookups or mutations" not in str(r):
             self.fail("eventing is still using xattrs for timers")
     self.undeploy_and_delete_function(body)
开发者ID:ritamcouchbase,项目名称:testrunner,代码行数:23,代码来源:eventing_dataset.py

示例2: test_eventing_processes_mutations_when_mutated_through_subdoc_api_and_set_expiry_through_sdk

# 需要导入模块: from couchbase.bucket import Bucket [as 别名]
# 或者: from couchbase.bucket.Bucket import mutate_in [as 别名]
 def test_eventing_processes_mutations_when_mutated_through_subdoc_api_and_set_expiry_through_sdk(self):
     # set expiry pager interval
     ClusterOperationHelper.flushctl_set(self.master, "exp_pager_stime", 1, bucket=self.src_bucket_name)
     url = 'couchbase://{ip}/{name}'.format(ip=self.master.ip, name=self.src_bucket_name)
     bucket = Bucket(url, username="cbadminbucket", password="password")
     for docid in ['customer123', 'customer1234', 'customer12345']:
         bucket.insert(docid, {'some': 'value'})
     body = self.create_save_function_body(self.function_name, self.handler_code,
                                           dcp_stream_boundary="from_now")
     # deploy eventing function
     self.deploy_function(body)
     # upserting a new sub-document
     bucket.mutate_in('customer123', SD.upsert('fax', '775-867-5309'))
     # inserting a sub-document
     bucket.mutate_in('customer1234', SD.insert('purchases.complete', [42, True, None], create_parents=True))
     # Creating and populating an array document
     bucket.mutate_in('customer12345', SD.array_append('purchases.complete', ['Hello'], create_parents=True))
     self.verify_eventing_results(self.function_name, 3, skip_stats_validation=True)
     for docid in ['customer123', 'customer1234', 'customer12345']:
         # set expiry on all the docs created using sub doc API
         bucket.touch(docid, ttl=5)
     self.sleep(10, "wait for expiry of the documents")
     # Wait for eventing to catch up with all the expiry mutations and verify results
     self.verify_eventing_results(self.function_name, 0, skip_stats_validation=True)
     self.undeploy_and_delete_function(body)
开发者ID:arod1987,项目名称:testrunner,代码行数:27,代码来源:eventing_dataset.py

示例3: test_eventing_processes_mutation_when_xattrs_is_updated

# 需要导入模块: from couchbase.bucket import Bucket [as 别名]
# 或者: from couchbase.bucket.Bucket import mutate_in [as 别名]
 def test_eventing_processes_mutation_when_xattrs_is_updated(self):
     url = 'couchbase://{ip}/{name}'.format(ip=self.master.ip, name=self.src_bucket_name)
     bucket = Bucket(url, username="cbadminbucket", password="password")
     for docid in ['customer123', 'customer1234', 'customer12345']:
         bucket.upsert(docid, {})
     body = self.create_save_function_body(self.function_name, self.handler_code,
                                           dcp_stream_boundary="from_now")
     # deploy eventing function
     self.deploy_function(body)
     # update multiple xattrs and update the documents
     for docid in ['customer123', 'customer1234', 'customer12345']:
         bucket.mutate_in(docid, SD.upsert('my1', {'value': 1}, xattr=True))
         bucket.mutate_in(docid, SD.upsert('my2', {'value': 2}, xattr=True))
         bucket.mutate_in(docid, SD.upsert('fax', '775-867-5309'))
     self.verify_eventing_results(self.function_name, 3, skip_stats_validation=True)
     # add new multiple xattrs , delete old xattrs and delete the documents
     for docid in ['customer123', 'customer1234', 'customer12345']:
         bucket.mutate_in(docid, SD.upsert('my3', {'value': 3}, xattr=True))
         bucket.mutate_in(docid, SD.upsert('my4', {'value': 4}, xattr=True))
         bucket.mutate_in(docid, SD.remove('my3', xattr=True))
         bucket.mutate_in(docid, SD.remove('my4', xattr=True))
         bucket.remove(docid)
     self.verify_eventing_results(self.function_name, 0, skip_stats_validation=True)
     self.undeploy_and_delete_function(body)
开发者ID:arod1987,项目名称:testrunner,代码行数:26,代码来源:eventing_dataset.py

示例4: SDKClient

# 需要导入模块: from couchbase.bucket import Bucket [as 别名]
# 或者: from couchbase.bucket.Bucket import mutate_in [as 别名]
class SDKClient(object):
    """Python SDK Client Implementation for testrunner - master branch Implementation"""

    def __init__(self, bucket, hosts = ["localhost"] , scheme = "couchbase",
                 ssl_path = None, uhm_options = None, password=None,
                 quiet=True, certpath = None, transcoder = None):
        self.connection_string = \
            self._createString(scheme = scheme, bucket = bucket, hosts = hosts,
                               certpath = certpath, uhm_options = uhm_options)
        self.password = password
        self.quiet = quiet
        self.transcoder = transcoder
        self.default_timeout = 0
        self._createConn()

    def _createString(self, scheme ="couchbase", bucket = None, hosts = ["localhost"], certpath = None, uhm_options = ""):
        connection_string = "{0}://{1}".format(scheme, ", ".join(hosts).replace(" ",""))
        if bucket != None:
            connection_string = "{0}/{1}".format(connection_string, bucket)
        if uhm_options != None:
            connection_string = "{0}?{1}".format(connection_string, uhm_options)
        if scheme == "couchbases":
            if "?" in connection_string:
                connection_string = "{0},certpath={1}".format(connection_string, certpath)
            else:
                connection_string = "{0}?certpath={1}".format(connection_string, certpath)
        return connection_string

    def _createConn(self):
        try:
            self.cb = CouchbaseBucket(self.connection_string, password = self.password,
                                  quiet = self.quiet, transcoder = self.transcoder)
            self.default_timeout = self.cb.timeout
        except BucketNotFoundError as e:
             raise

    def reconnect(self):
        self.cb.close()
        self._createConn()

    def close(self):
        self.cb._close()

    def counter_in(self, key, path, delta, create_parents=True, cas=0, ttl=0, persist_to=0, replicate_to=0):
        try:
            return self.cb.counter_in(key, path, delta, create_parents= create_parents, cas= cas, ttl= ttl, persist_to= persist_to, replicate_to= replicate_to)
        except CouchbaseError as e:
            raise

    def arrayappend_in(self, key, path, value, create_parents=True, cas=0, ttl=0, persist_to=0, replicate_to=0):
        try:
            return self.cb.arrayappend_in(key, path, value, create_parents=create_parents, cas=cas, ttl=ttl, persist_to=persist_to, replicate_to=replicate_to)
        except CouchbaseError as e:
            raise

    def arrayprepend_in(self, key, path, value, create_parents=True, cas=0, ttl=0, persist_to=0, replicate_to=0):
        try:
            return self.cb.arrayprepend_in(key, path, value, create_parents=create_parents, cas=cas, ttl=ttl, persist_to=persist_to, replicate_to=replicate_to)
        except CouchbaseError as e:
            raise

    def arrayaddunique_in(self, key, path, value, create_parents=True, cas=0, ttl=0, persist_to=0, replicate_to=0):
        try:
            return self.cb.addunique_in(key, path, value, create_parents=create_parents, cas=cas, ttl=ttl, persist_to=persist_to, replicate_to=replicate_to)
        except CouchbaseError as e:
            raise

    def arrayinsert_in(self, key, path, value, cas=0, ttl=0, persist_to=0, replicate_to=0):
        try:
            return self.cb.arrayinsert_in(key, path, value, cas=cas, ttl=ttl, persist_to=persist_to, replicate_to=replicate_to)
        except CouchbaseError as e:
            raise

    def remove_in(self, key, path,  cas=0, ttl=0):
        try:
            self.cb.remove_in(key, path, cas = cas, ttl = ttl)
        except CouchbaseError as e:
            raise

    def mutate_in(self, key, *specs, **kwargs):
        try:
            self.cb.mutate_in(key, *specs, **kwargs)
        except CouchbaseError as e:
            raise

    def lookup_in(self, key, *specs, **kwargs):
        try:
            self.cb.lookup_in(key, *specs, **kwargs)
        except CouchbaseError as e:
            raise

    def get_in(self, key, path):
        try:
            result = self.cb.get_in(key, path)
            return self.__translate_get(result)
        except CouchbaseError as e:
            raise

    def exists_in(self, key, path):
        try:
#.........这里部分代码省略.........
开发者ID:EricACooper,项目名称:testrunner,代码行数:103,代码来源:sdk_client.py

示例5: run

# 需要导入模块: from couchbase.bucket import Bucket [as 别名]
# 或者: from couchbase.bucket.Bucket import mutate_in [as 别名]
 def run(self, *args, **kw):
     cb = SDK_Bucket(CONNSTR)
     for x in range(ITERATIONS):
         cb.mutate_in(DOCID, SD.array_append('recs', 1))
开发者ID:prasanna135,项目名称:testrunner,代码行数:6,代码来源:subdoc_nested_dataset.py


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