multi_get_opt

同时读一条hashkey的多条sortkey数据, 读取的数据根据multi_get_options参数指定的模式确定。

  1. def multi_get_opt(self, hash_key,
  2. start_sort_key, stop_sort_key,
  3. multi_get_options,
  4. max_kv_count=100,
  5. max_kv_size=1000000,
  6. timeout=0):
  7. """
  8. Get multiple values stored in hash_key, and sort key range in [start_sort_key, stop_sort_key) as default.
  9. :param hash_key: (str) which hash key used for this API.
  10. :param start_sort_key: (str) returned k-v pairs is start from start_sort_key.
  11. :param stop_sort_key: (str) returned k-v pairs is stop at stop_sort_key.
  12. :param multi_get_options: (MultiGetOptions) configurable multi_get options.
  13. :param max_kv_count: (int) max count of k-v pairs to be fetched. max_fetch_count <= 0 means no limit.
  14. :param max_kv_size: (int) max total data size of k-v pairs to be fetched. max_fetch_size <= 0 means no limit.
  15. :param timeout: (int) how long will the operation timeout in milliseconds.
  16. if timeout > 0, it is a timeout value for current operation,
  17. else the timeout value specified to create the instance will be used.
  18. :return: (tuple<error_types.code.value, dict>) (code, kvs)
  19. code: error_types.ERR_OK.value when data got succeed.
  20. kvs: <sort_key, value> pairs in dict.
  21. """

其中,MultiGetOptions可以指定sortkey的范围、是否包含边界、子串匹配、是否返回value、是否逆序等,具体定义如下:

  1. class MultiGetOptions(object):
  2. """
  3. configurable options for multi_get.
  4. """
  5. def __init__(self):
  6. self.start_inclusive = True
  7. self.stop_inclusive = False
  8. self.sortkey_filter_type = filter_type.FT_NO_FILTER
  9. self.sortkey_filter_pattern = ""
  10. self.no_value = False
  11. self.reverse = False
  12. class filter_type:
  13. FT_NO_FILTER = 0
  14. FT_MATCH_ANYWHERE = 1
  15. FT_MATCH_PREFIX = 2
  16. FT_MATCH_POSTFIX = 3