English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Advanced Redis Tutorial

Redis Lists (List)

Redis Lrange Command Redis Lrange returns elements within the specified range of the list, specified by the offset START and END. 1 where 0 represents the first element of the list, You can also use negative indices to represent the second element of the list, and so on. -1 represents the last element of the list, -2 represents the second-to-last element of the list, and so on.

Syntax

The basic syntax of the redis Lrange command is as follows:

redis 127.0.0.1:6379> LRANGE KEY_NAME START END

Available Version

>= 1.0.0

Return Value

A list containing elements within the specified range.

Online Examples

redis> RPUSH mylist "one"
(integer) 1
redis> RPUSH mylist "two"
(integer) 2
redis> RPUSH mylist "three"
(integer) 3
redis> LRANGE mylist 0 0
1) "one"
redis> LRANGE mylist -3 2
1) "one"
2) "two"
3) "three"
redis> LRANGE mylist -100 100
1) "one"
2) "two"
3) "three"
redis> LRANGE mylist 5 10
(empty list or set)
redis> 

Redis Lists (List)