Javatpoint Logo
Javatpoint Logo

Redis Lists

Redis lists can be defined as a list of strings, sorted by insertion order. You can add elements in Redis lists in the head or the tail of the list.

A list can contain more than 4 billion elements.

Example

Redis Lists 1

Redis Lists Commands

Index Command Description
1 BLPOP key1 [key2 ] timeout It is used to remove and get the first element in a list, or blocks until one is available.
2 BRPOP key1 [key2 ] timeout It is used to remove and get the last element in a list, or blocks until one is available.
3 BRPOPLPUSH source destination timeout It is used to pop a value from a list, pushes it to another list and returns it; or blocks until one is available.
4 LINDEX key index It is used to get an element from a list by its index.
5 LINSERT key before|after pivot value It is used to insert an element before or after another element in a list.
6 LLEN key It is used to get the length of a list.
7 LPOP key It is used to remove and get the first element in a list.
8 LPUSH key value1 [value2] It is used to prepend one or multiple values to a list.
9 LPUSHX key value It is used to prepend a value to a list, only if the list exists.
10 LRANGE key start stop It is used to get a range of elements from a list.
11 LREM key count value It is used to remove elements from a list.
12 LSET key index value It is used to set the value of an element in a list by its index.
13 LTRIM key start stop It is used to trim a list to the specified range.
14 RPOP key It is used to remove and get the last element in a list.
15 RPOPLPUSH source destination It is used to remove the last element in a list, append it to another list and returns it.
16 RPUSH key value1 [value2] It is used to append one or multiple values to a list.
17 RPUSHX key value It is used to append a value to a list, only if the list exists.

Next TopicRedis Sets




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA