The Reids list is a simple list of strings, sorted in order of insertion. You can add elements to the list at the end of the head or list of Redis.
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, the three values are inserted into the Redis list named tutorials using the Lpush command.
Reids List of commands
Some basic commands are listed as shown in the following table:
S.N. |
Command & Description |
1 |
Blpop key1 [Key2] Timeout Remove and get the first element in the list, or block until there is an available |
2 |
Brpop key1 [Key2] Timeout Remove and get the last element in the list, or block until there are available |
3 |
Brpoplpush Source Destination Timeout POPs a value from the list, pushes it to another list and returns it, or blocks until there are available |
4 |
LINDEX Key Index Get the corresponding element from a list with its index |
5 |
Linsert Key before| After pivot value Insert an element after or before another element in the list |
6 |
Llen Key Get the length of a list |
7 |
Lpop Key Gets and removes the first element in a list |
8 |
Lpush key value1 [value2] Add a list of one or more values in front |
9 |
Lpushx Key value Precede with a list of values, only if the list exists |
10 |
Lrange Key Start stop Get various elements from a list |
11 |
Lrem Key Count value Remove an element from the list |
12 |
LSET Key index value Set the value of an element in the index in the list |
13 |
LTRIM Key Start stop Trim list to specified range |
14 |
Rpop key removes and gets the last element in the list |
15 |
Rpuplpush Source Destination Removes the list of the last element, attaches it to 21 lists, and returns it |
16 |
Rpush key value1 [value2] Add one or more values to the list |
17 |
Rpushx Key value Add a list of values only if the list exists |
Redis QuickStart-Redis list (10)