Skip to content

Feature Request: Support ZRANGE arguments (BYSCORE, BYLEX, REV, LIMIT) #3681

@thachlp

Description

@thachlp

Feature Request

Is your feature request related to a problem? Please describe

Redis 6.2.0 deprecated several Sorted Set commands (ZRANGEBYSCORE, ZRANGEBYLEX, ZREVRANGE, etc.) in favor of an enhanced ZRANGE command. Currently, Lettuce lacks the ZRANGE overloads to support the new BYSCORE, BYLEX, REV, and LIMIT flags, leaving users without a modern migration path for the deprecated APIs discussed in #3615.

Describe the solution you'd like

Enhance Lettuce to support the unified ZRANGE syntax by:

  1. Updating ZRangeArgs : Add methods .byScore(), .byLex(), and .rev().
  2. Adding Overloads: Implement zrange methods in RedisSortedSetCommands that accept ZRangeArgs.
  3. Protocol Mapping: Ensure the command is encoded as ZRANGE <key> <min> <max> [BYSCORE|BYLEX] [REV] [LIMIT offset count].

Drawbacks: Minimal. This is an additive change to maintain parity with Redis 6.2+.

Describe alternatives you've considered

Using dispatch to send custom commands, but this bypasses Lettuce's type-safety and fluent API benefits.

Teachability, Documentation, Adoption, Migration Strategy

Users can migrate from deprecated commands to the new unified zrange easily:

Old (Deprecated):

// ZRANGEBYSCORE key 0 100
redis.zrangebyscore("mykey", Range.from(Boundary.including(0), Boundary.including(100)));

New (Unified):

// ZRANGE key 0 100 BYSCORE
redis.zrange("mykey", Range.from(Boundary.including(0), Boundary.including(100)), ZRangeArgs.builder().byScore());

Note: For REV operations, users should be aware that ZRANGE ... REV maintains a consistent min max order, unlike the old ZREV... commands which required inverted max min parameters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions