Skip to main content

Overview

Returns the specified elements of the list stored at key. The offsets start and end are zero-based indexes. These offsets can also be negative numbers indicating offsets from the end of the list.

Method Signature

Parameters

key
string
required
The key of the list.
start
number
required
The starting index (zero-based). Negative values indicate offsets from the end of the list (e.g., -1 is the last element, -2 is the second-to-last).
end
number
required
The ending index (zero-based, inclusive). Negative values indicate offsets from the end of the list. Use -1 to get all elements from start to the end of the list.

Return Value

elements
TResult[]
An array of elements in the specified range. Returns an empty array if the list does not exist or the range is out of bounds.

Examples

Basic Usage

Using Negative Indexes

Working with Objects

Pagination

Getting Recent Items

Viewing Queue Contents

See Also

  • LLEN - Get the length of a list
  • LINDEX - Get an element by index
  • LPUSH - Insert elements at the head of a list
  • RPUSH - Insert elements at the tail of a list