开发者

Efficiently accessing arbitrary subsets of a master sorted set in Redis

开发者 https://www.devze.com 2023-02-04 23:53 出处:网络
Given a large sorted set with rapidly changing scores/weights, what\'s the most efficient way to maintain subsets and开发者_StackOverflow社区 access those subsets in the master set\'s order?You have a

Given a large sorted set with rapidly changing scores/weights, what's the most efficient way to maintain subsets and开发者_StackOverflow社区 access those subsets in the master set's order?


You have a couple of options for this:

  • Update scores in the superset and when you need to read the subset call ZINTERSTORE with subset weighting set to 0 so the result is the subset with scores from the superset.
  • When updating the scores, write to the subsets as well as the superset.

The most appropriate option will depend on what you need to optimise for - read, write, memory or simplicity. How the subsets are determined and the size of the sets relative to the number of updates may also have an impact.

0

精彩评论

暂无评论...
验证码 换一张
取 消