Khóa học miễn phí Redis – Lists nhận dự án làm có lương

Redis – Lists



Redis Lists are simply lists of strings, sorted by insertion order. You can add elements in Redis lists in the head or the tail of the list.

Maximum length of a list is 232 – 1 elements (4294967295, more than 4 billion of elements per list).

Example

redis 127.0.0.1:6379> LPUSH tutorials redis 
(integer) 1 
redis 127.0.0.1:6379> LPUSH tutorials mongodb 
(integer) 2 
redis 127.0.0.1:6379> LPUSH tutorials mysql 
(integer) 3 
redis 127.0.0.1:6379> LRANGE tutorials 0 10  
1) "mysql" 
2) "mongodb" 
3) "redis"

In the above example, three values are inserted in Redis list named ‘tutorials’ by the command LPUSH.

Redis Lists Commands

Following table lists some basic commands related to lists.

Sr.No Command & Description
1

Removes and gets the first element in a list, or blocks until one is available

2

Removes and gets the last element in a list, or blocks until one is available

3

Pops a value from a list, pushes it to another list and returns it; or blocks until one is available

4

Gets an element from a list by its index

5

Inserts an element before or after another element in a list

6

Gets the length of a list

7

Removes and gets the first element in a list

8

Prepends one or multiple values to a list

9

Prepends a value to a list, only if the list exists

10

Gets a range of elements from a list

11

Removes elements from a list

12

Sets the value of an element in a list by its index

13

Trims a list to the specified range

14

Removes and gets the last element in a list

15

Removes the last element in a list, appends it to another list and returns it

16

Appends one or multiple values to a list

17

Appends a value to a list, only if the list exists

Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc