List chain / list structure
Lpush key value
Function: insert a value into the head of the link
Rpop key
Function: return and delete the element at the end of the list
Rpush,lpop: no explanation
Lrange key start stop (starting at 0)
Lrange key 6 6 views data with index 6
Lrange key 2 5 views data with indexes from 2 (including 2) to 5 (including 5)
Function: returns the elements in [start, stop] in the linked list
Rule: the left starts at 0 and the right starts at-1 (0-1 selects all elements)
Lrem key count value
View 5 pieces of data on the right side of the list:
Lrange key-5-1
Purpose: remove the value value from the key linked list
Note: end after deleting the absolute value of count (value)
Delete Count > 0 from the header
Count llen task
(integer) 3
Redis 127.0.0.1 purl 6379 >
L × × × ert key after | before search value
Function: look for 'search',' in the key linked list and before the search value | after. Insert value
Note: once a search is found, the command ends, so multiple value will not be inserted.
There are multiple inserts of values being queried:
Rpoplpush source dest
Function: take out the tail of source and put it on the head of dest
And return the cell value
Scenario: task + bak double linked list completes the security queue
Business logic:
1:Rpoplpush task bak
2: receive the return value and do business processing
3: if successful, rpop bak clears the task. If unsuccessful, get the task from the bak table next time.
Brpop, blpop key timeout
Function: wait for the tail / header element of the key to pop up
Timeout is the wait timeout
If timeout is 0, wait forever
Scenario: long polling Ajax, can be used when chatting online
Note:
Since a list can store millions of pieces of data, never rashly list all the data in a list, otherwise it may result in a large amount of data output and instantly deplete the system's 1max 0 resources.
It should be: first check the length of the list, if it is determined that the amount of data is small, then list all the values; if the amount of data is large, you can use the index to view the first few pieces of data and the last few pieces of data.