Redis Link Linked list structure

Source: Internet
Author: User

Role: Inserting values into the link header

Rpop Key

Function: Returns and deletes the chain footer element

Lrange Key Start  stop

Function: Returns the element in the list [Start, stop]

Rule: The left number starts at 0 and the right number starts at 1

Lrem Key Count value

Function: Removes the value from the key linked list

Note: Delete the absolute value of count after the end of value

Count>0 Remove from table header

Count<0 Delete from footer

LTrim Key Start stop

function : Cut Key the corresponding link , Cut [Start,stop] some , and re-assign the paragraph to Key

Lindex Key Index

function : return Index the value on the index ,

as lindex Key 2

Llen Key

function : count the number of elements in a linked table

Redis 127.0.0.1:6379> Llen Task

(integer) 3

Redis 127.0.0.1:6379>

Linsert  key After|before Search value

function: in theKeylinked list to find' Search ',and inSearchvalue before|after,.Insertvalue

Note : once you find a Search after , the order is over. , Therefore, you will not insert multiple value  

Rpoplpush Source Dest
+ Bak doubly linked list complete secure queue Task List                             bak listing         1   1   1                         1   1   1      business logic:1: Rpoplpush Task bak2: Receives the return value and does business processing 3: If successful, Rpop bak clears the task. If unsuccessful, take the task from the Bak table next time

Brpop, Blpop  key timeout

function : waiting to pop up Key the tail / Head Element ,

Timeout to wait for a time-out

if Timeout to be 0, is waiting

Scenario : long polling Ajax, when chatting online , can use

Setbit Real-world scenarios: 100 million users, each user login/do any action, remember as active today, otherwise recorded as inactive Weekly: award-winning active Users: Monthly commentary for 7 consecutive days, etc... Idea: Userid DT active1         -- -- -  11        --0726   1if it is placed in a table,1: The table grows sharply,2: To use the group, sum operation, the calculation is slower: Bitmap method bit-mapLog0721: '011001...............0' ... log0726: '011001...............0' Log0727: '0110000.............1'1: Log User login: Generate a bitmap daily by date, after the user logs on, the bit value on the USER_ID bit is set to 12: Calculates the 1-week bitmap and the 1-bit, which is the user Redis for continuous login127.0.0.1:6379> Setbit Mon100000000 0(integer)0Redis127.0.0.1:6379> Setbit Mon3 1(integer)0Redis127.0.0.1:6379> Setbit Mon5 1(integer)0Redis127.0.0.1:6379> Setbit Mon7 1(integer)0Redis127.0.0.1:6379> setbit Thur100000000 0(integer)0Redis127.0.0.1:6379> setbit Thur3 1(integer)0Redis127.0.0.1:6379> setbit Thur5 1(integer)0Redis127.0.0.1:6379> setbit Thur8 1(integer)0Redis127.0.0.1:6379> Setbit Wen100000000 0(integer)0Redis127.0.0.1:6379> Setbit Wen3 1(integer)0Redis127.0.0.1:6379> Setbit Wen4 1(integer)0Redis127.0.0.1:6379> Setbit Wen6 1(integer)0Redis127.0.0.1:6379>bitop and res Mon Feb wen (integer)12500001For example, the advantages:1: Save space, 100 million people daily landing situation, with 100 million bit, about 1200WByte, about 10M characters can be expressed2: Convenient calculation

  

LTrim Key Start stop

Redis Link Linked list structure

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.