multi_get_opt
同时读一条hashkey的多条sortkey数据, 读取的数据根据multi_get_options
参数指定的模式确定。
def multi_get_opt(self, hash_key,
start_sort_key, stop_sort_key,
multi_get_options,
max_kv_count=100,
max_kv_size=1000000,
timeout=0):
"""
Get multiple values stored in hash_key, and sort key range in [start_sort_key, stop_sort_key) as default.
:param hash_key: (str) which hash key used for this API.
:param start_sort_key: (str) returned k-v pairs is start from start_sort_key.
:param stop_sort_key: (str) returned k-v pairs is stop at stop_sort_key.
:param multi_get_options: (MultiGetOptions) configurable multi_get options.
:param max_kv_count: (int) max count of k-v pairs to be fetched. max_fetch_count <= 0 means no limit.
:param max_kv_size: (int) max total data size of k-v pairs to be fetched. max_fetch_size <= 0 means no limit.
:param timeout: (int) how long will the operation timeout in milliseconds.
if timeout > 0, it is a timeout value for current operation,
else the timeout value specified to create the instance will be used.
:return: (tuple<error_types.code.value, dict>) (code, kvs)
code: error_types.ERR_OK.value when data got succeed.
kvs: <sort_key, value> pairs in dict.
"""
其中,MultiGetOptions
可以指定sortkey的范围、是否包含边界、子串匹配、是否返回value、是否逆序等,具体定义如下:
class MultiGetOptions(object):
"""
configurable options for multi_get.
"""
def __init__(self):
self.start_inclusive = True
self.stop_inclusive = False
self.sortkey_filter_type = filter_type.FT_NO_FILTER
self.sortkey_filter_pattern = ""
self.no_value = False
self.reverse = False
class filter_type:
FT_NO_FILTER = 0
FT_MATCH_ANYWHERE = 1
FT_MATCH_PREFIX = 2
FT_MATCH_POSTFIX = 3