Redis Advanced icon

Redis Advanced

Get, send and update data in Redis with enhanced operations

Sorted Set Range

AI-generated

Summary

Retrieve a range of members from a Redis sorted set with optional inclusion of their scores.

Inputs

  • Sorted Set (required) — The name of the sorted set from which to retrieve members.
  • Start — The start index for the range (inclusive). Defaults to 0.
  • Stop — The stop index for the range (inclusive). Use -1 to indicate the end of the sorted set. Defaults to -1.
  • With Scores — Whether to include the members' scores in the returned result. Defaults to false.

Output shape

A list of JSON objects, each containing the retrieved members. If 'With Scores' is enabled, each entry includes the member along with its score; otherwise, only members are returned.

The range uses zero-based inclusive indices. Negative indices are supported to specify offsets from the end (-1 corresponds to the last element). Returned data structure depends on the 'With Scores' parameter.

Examples

Example 1: Retrieve all members from a sorted set named 'leaderboard' with their scores.

Set 'Sorted Set' to 'leaderboard', 'Start' to 0, 'Stop' to -1, and 'With Scores' to true.

Discussion