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


Python VBucketAwareMemcached.generic_request方法代码示例

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


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

示例1: test_new_response_fields

# 需要导入模块: from memcached.helper.data_helper import VBucketAwareMemcached [as 别名]
# 或者: from memcached.helper.data_helper.VBucketAwareMemcached import generic_request [as 别名]
    def test_new_response_fields(self):

        self.log.info('\n\nStarting test_new_response_fields')

        client = VBucketAwareMemcached(RestConnection(self.master), 'default')


        h = client.sendHellos( memcacheConstants.PROTOCOL_BINARY_FEATURE_MUTATION_SEQNO );



        set_resp = self.extract_vbucket_uuid_and_seqno( client.set('test1key', 0, 0, '123456789') )

        # test the inplace operations
        test = client.generic_request(client.memcached('test1key').set, 'test1key', 0, 0,'totally new value')
        replace_resp = self.extract_vbucket_uuid_and_seqno(
            client.generic_request( client.memcached('test1key').replace,  'test1key', 0, 0,'totally new value') )
        self.verify_vbucket_and_seqno( set_resp, replace_resp, 'replace')

        append_resp = self.extract_vbucket_uuid_and_seqno(
            client.generic_request( client.memcached('test1key').append, 'test1key', 'appended data') )
        self.verify_vbucket_and_seqno(replace_resp, append_resp, 'append')

        prepend_resp = self.extract_vbucket_uuid_and_seqno(
            client.generic_request( client.memcached('test1key').prepend, 'test1key', 'prepended data') )
        self.verify_vbucket_and_seqno(append_resp, prepend_resp, 'prepend')


        # and finally do the delete
        delete_resp = self.extract_vbucket_uuid_and_seqno(
            client.generic_request( client.memcached('test1key').delete,'test1key') )
        self.verify_vbucket_and_seqno( set_resp, delete_resp, 'delete')


        #meta commands under construction
        # test the 'meta' commands
        TEST_SEQNO = 123
        TEST_CAS = 456

        set_with_meta_resp = client.generic_request(
            client.memcached('test1keyformeta').set_with_meta, 'test1keyformeta', 0, 0, TEST_SEQNO, TEST_CAS, '123456789')
        set_meta_vbucket_uuid, set_meta_seqno = struct.unpack('>QQ', set_with_meta_resp[2])
        set_with_meta_dict = {'vbucket_uuid':set_meta_vbucket_uuid, 'seqno': set_meta_seqno}



        get_meta_resp = client.generic_request(client.memcached( 'test1keyformeta').getMeta, 'test1keyformeta')
        self.assertTrue(TEST_SEQNO == get_meta_resp[3], \
               msg='get meta seqno does not match as set. Expected {0}, actual {1}'.format(TEST_SEQNO,get_meta_resp[3]) )
        self.assertTrue(TEST_CAS == get_meta_resp[4], \
               msg='get meta cas does not match as set. Expected {0}, actual {1}'.format(TEST_CAS,get_meta_resp[4]) )


        #   def del_with_meta(self, key, exp, flags, seqno, old_cas, new_cas, vbucket= -1):
        del_with_meta_resp = client.generic_request(
            client.memcached('test1keyformeta').del_with_meta,'test1keyformeta', 0, 0, TEST_SEQNO, TEST_CAS, TEST_CAS+1)
        vbucket_uuid, seqno = struct.unpack('>QQ', del_with_meta_resp[2])
        del_with_meta_dict = {'vbucket_uuid':vbucket_uuid, 'seqno': seqno}

        self.verify_vbucket_and_seqno( set_with_meta_dict, del_with_meta_dict, 'set/del with meta')





        #  do some integer operations
        set_resp = self.extract_vbucket_uuid_and_seqno( client.set('key-for-integer-value', 0, 0, '123') )
        incr_resp = client.generic_request(client.memcached('key-for-integer-value').incr, 'key-for-integer-value')
        incr_resp_dict = {'vbucket_uuid':incr_resp[2], 'seqno':incr_resp[3]}
        self.verify_vbucket_and_seqno(set_resp, incr_resp_dict, 'incr')


        decr_resp = client.generic_request(client.memcached('key-for-integer-value').decr,'key-for-integer-value')
        decr_resp_dict = {'vbucket_uuid':decr_resp[2], 'seqno':decr_resp[3]}
        self.verify_vbucket_and_seqno(incr_resp_dict, decr_resp_dict, 'decr')


        add_resp = self.extract_vbucket_uuid_and_seqno(
            client.generic_request( client.memcached('totally new key').add, 'totally new key', 0, 0,'totally new value') )

        self.assertTrue( add_resp['vbucket_uuid'] > 0, msg='Add request vbucket uuid is zero')

        self.log.info('\n\nComplete test_new_response_fields\n\n')
开发者ID:lichia,项目名称:testrunner,代码行数:85,代码来源:observeseqnotests.py


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