Redis List – Commands to manage a list value in redis datastore
5 years ago Lalit Bhagtani 0
Lists are a sequence of strings sorted by insertion order, In Redis, list can be store as a value at key and various redis commands are used to store, manage and retrieved a list value stored in redis database. The syntax for using redis commands is as follows :-
Syntax :-
redis host:post> <Command Name> <key name>
Example :-
Redis List Value Commands :-
Some of the important commands to manage list value in redis database are as follows :-
S.No | Command | Description |
---|---|---|
1 | BLPOP | Return and remove first element of the list or blocks it until one is available |
2 | BRPOP | Return and remove last element of the list or blocks it until one is available |
3 | BRPOPLPUSH | Removes last element from a list and insert it into another list or blocks it until one is available |
4 | LINDEX | Returns an element from a list by its index |
5 | LINSERT | Insert an element before or after another element of a list |
6 | LLEN | Returns length of the list |
7 | LPOP | Return and remove first element of the list |
8 | LPUSH | Insert one or more element at head of the list |
9 | LPUSHX | Insert element at head of the list, only if it exist |
10 | LRANGE | Returns a range of element from the list |
11 | LREM | Removes element from the list |
12 | LSET | Sets an element to a list by its index |
13 | LTRIM | Trim a list to the specified range |
14 | RPOP | Return and remove last element of the list |
15 | RPOPLPUSH | Removes last element from a list and insert it into another list |
16 | RPUSH | Insert one or more element at tail of the list |
17 | RPUSHX | Insert element at tail of the list, only if it exist |
References :-
That’s all for Redis list value and commands used to store and manage it in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.