List data type
List is a linked list structure, the main function is Push,pop, get all the values of a range and so on. In operation, key is understood as the name of the list, and the Redis list is actually a doubly linked list in which each child element is a string type, and we can add the deletion element from the head or tail of the list by Push,pop operation, so that the list can be both a stack and a queue
Lpush: Adding a string element to the list from the head
Example:
Lpush list1 ' Hello '
Lpush list1 ' World '
Lpush list1 ' ZJZ '
Lrange List1 0-2
Output: ZJZ World
Linsert insert at a specific location
Lpush List2 One
Lpush List2 Three
Linsert List2 before one outputs three-one head to front
LSet list2 0 ' AAA ' Replace the value of the element labeled 0 with AAA
Lrem List2 2 One removes two elements from the head, starting with the header (n<0 means delete from the tail, n=0 means delete all)
LTrim List2 1-1 retains elements of 1 to-1, all others removed
Lpop List2 pops an element from the head and returns the deleted element
Rpop List2 pops an element from the tail and returns the deleted element
Rpoplpush list1 list2 pop-up elements from List1 's tail and add to List2 's head
Lindex List1 1 Returns the value of the element labeled 1 in the List1, supporting negative numbers
Rpush list2 ' xxxx ' press in from the rear
Llen List2 Returns the length of the linked list
Redis list data type