Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

List chain / list structure

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report