Skip to content

feat(commands): ZSet 6.2+ additions (ZRANGESTORE, ZDIFF, ZUNION, ZINTER, ZINTERCARD, ZMSCORE, ZRANDMEMBER, ZMPOP) #59

Description

@TinDang97

Summary

Moon ships the core zset command set but is missing the non-STORE aggregation variants and several Redis 6.2 / 7.0 additions. Most application code has workarounds via ZINTERSTORE/ZUNIONSTORE + temp keys, but modern clients (redis-py, ioredis, go-redis) call the inline versions directly.

Missing commands

  • ZRANGESTORE dst src min max [BYSCORE|BYLEX] [REV] [LIMIT o c]
  • ZDIFF numkeys key [key ...] [WITHSCORES]
  • ZDIFFSTORE dst numkeys key [key ...]
  • ZUNION numkeys key [key ...] [WEIGHTS ...] [AGGREGATE ...] [WITHSCORES]
  • ZINTER numkeys key [key ...] [WEIGHTS ...] [AGGREGATE ...] [WITHSCORES]
  • ZINTERCARD numkeys key [key ...] [LIMIT limit]
  • ZMSCORE key member [member ...]
  • ZRANDMEMBER key [count [WITHSCORES]]
  • ZMPOP numkeys key [key ...] MIN|MAX [COUNT count]

Design notes

  • ZINTER/ZUNION/ZDIFF are *STORE logic minus the final write — refactor existing storage handlers to return a Vec<(Bytes, f64)> that either gets written or serialized to the response.
  • ZRANDMEMBER with count ≥ 0: unique sampling (Fisher-Yates over skiplist). Count < 0: with replacement. Match Redis distribution exactly (consistency tests will catch drift).
  • ZMPOP shares plumbing with LMPOP (feat(commands): list/hash/set convenience variants (LPUSHX/RPUSHX/LMPOP/HRANDFIELD/SMOVE/SINTERCARD) #60).
  • Watch the aggregate aliasing rules for AGGREGATE MIN/MAX/SUM — easy to get wrong for weighted cases.

Acceptance criteria

  • Consistency test for each command with at least: single key, multi-key, empty key, WITHSCORES, WEIGHTS where applicable.
  • No allocation regressions on the existing ZINTERSTORE/ZUNIONSTORE paths.

References

  • Redis source: src/t_zset.c

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestredis-parityMissing Redis commands / parity gaps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions