当前位置:网站首页>The five basic data structures of redis are in-depth and application scenarios
The five basic data structures of redis are in-depth and application scenarios
2022-07-06 09:14:00 【~Pompeii】
Catalog
- Redis The five basic data structures are in-depth 、 Application scenarios
- 0. Business data
- 1.string
- 1.2String Basic operation
- 1.3String Application scenarios
- 1.4set And mset Choice problem
- 1.5.string matters needing attention
- 1.6string As a numerical operation
- 1.7 Application scenarios - Optimize table splitting operation
- 1.8 Application scenarios - Popular product recommendation
- 1.9 Application scenarios - Weibo fans
- 2.Hash
- 2.1Hash Introduce
- 2.2Hash Basic operation
- 2.3Hash Application scenarios
- 2.4Hash matters needing attention
- 2.5 Application scenarios - E-commerce website shopping cart design and implementation
- 2.6 Application scenarios - Rush to buy restricted goods
- 2.7 Application scenarios -string Store the object (json) And hash Store the object
- 3.List
- 4.Set
- 4.1Set Introduce
- 4.2Set Basic operation
- 4.3Set Application scenarios
- 4.4Set matters needing attention
- 4.5 Application scenarios - Hot recommendation
- 4.6 Application scenarios - Association search
- 4.7 Application scenarios - Website visit to remove duplication
- 4.9 Application scenarios - Black and white list
- 5.SortedSet
- 6.redis Business scenario - Voice call
- 7.redis Business scenario - Chat top
- 8.redis Application scenarios
Redis The five basic data structures are in-depth 、 Application scenarios
0. Business data
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-dNSyhCsQ-1656900930124)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703100854100.png)]](/img/f9/c24649d5bfebe75f4f342f7b9324b7.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-w4S7Y44B-1656900930125)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703100910633.png)]](/img/a7/bb9514caa8a4112285b634d253757e.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-vjoJB05L-1656900930126)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703100921223.png)]](/img/e6/77cb221c5ac42ab2ac9617f99ef283.png)
1.string
String The type is Redis The most commonly used type in , Internal implementation is through SDS(Simple Dynamic String ) To store the .SDS Be similar to Java Medium ArrayList, The frequent allocation of memory can be reduced by pre allocating redundant space .
Stored data : Single data , The simplest type of data storage , It is also the most commonly used data storage type
The format of data storage : One storage space holds one data
Store content : You usually use strings , If the string is presented as an integer , It can be used as a digital operation
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-jsjZL2LX-1656900930127)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703101311843.png)]](/img/8b/2b39112a4cc4aa9c8c5afae41625af.png)
1.2String Basic operation
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-EFO3AeI8-1656900930128)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703101405181.png)]](/img/df/726479f4dc33a5eb35a95a18af9944.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-5hK0g7fH-1656900930128)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703101420561.png)]](/img/f7/3adca3e5b522ae12acb8bb8b399548.png)
1.3String Application scenarios
String The practical application scenarios of are more extensive :
1. Caching function :String String is the most commonly used data type , not only Redis, Every language is the most basic type , therefore , utilize Redis As caching , With other databases as the storage layer , utilize Redis Support for high concurrency , It can greatly speed up the reading and writing speed of the system 、 And reduce the pressure on the back-end database .
2. Counter : Many systems use Redis As the real-time counter of the system , It can quickly realize the function of counting and querying . And the final data results can be stored permanently in the database or other storage media at a specific time .
3. Share users Session: The user refreshes the interface again , You may need to access the data to log in again , Or visit the page cache Cookie, But it can be used Redis The user's Session centralized management , In this mode, we only need to guarantee Redis High availability , Every time a user Session The update and acquisition of can be completed quickly . Greatly improved efficiency .//
1.4set And mset Choice problem
By the time 3 Part of it is made up of : The client sends instructions to redisd Time for +redis Execution time +redis Time to return the result to the client ;
Let's assume The client sends instructions to redisd Time for ==redis Time to return the result to the client
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-ekrv84ai-1656900930129)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703102933420.png)]](/img/52/2bd104f939199ecf125517053bf39b.png)
1.5.string matters needing attention
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-7in5GnmE-1656900930129)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703103306759.png)]](/img/14/13c37eedc6be48c985024211c38643.png)
1.6string As a numerical operation
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-S7nUI0xX-1656900930130)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703103825357.png)]](/img/bf/9c9225334a2f0e1278f39b8c685b3c.png)
1.7 Application scenarios - Optimize table splitting operation
Tip1: redis Used to control the database table primary key id, Provide generation strategy for database table primary key , Ensure the uniqueness of the primary key of the database table
This scheme is applicable to all databases , And support database cluster
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-2zy1iQEX-1656900930131)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703103922946.png)]](/img/f8/eb4ea7264052f64ce3a7dda6da071b.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-QRtqPLg1-1656900930131)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703104640366.png)]](/img/0e/34d57a606e213ef3af55d87cc9a7f6.png)
1.8 Application scenarios - Popular product recommendation
Tip2:redis Control the lifecycle of data , Control business behavior through data failure , Applicable to all operations with time limited control
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-YLGvfk0V-1656900930132)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703104742196.png)]](/img/5e/63b648389607b3b05be3e3845d1271.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-oUhXsKoJ-1656900930132)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703104829685.png)]](/img/19/88deaac7ef7f3b36435dd7efc024f0.png)
1.9 Application scenarios - Weibo fans
Tip3:redis It can be applied to all kinds of structured and unstructured high heat data access acceleration
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-RXRHhV1w-1656900930133)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703104944858.png)]](/img/da/e498df003244a0f06a51b780afff10.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-jJ8QYRts-1656900930133)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703104957547.png)]](/img/5d/20c81701533871b70cb6063fccda8b.png)
2.Hash
2.1Hash Introduce
This is similar Map A structure of , In general, structured data can be used , Like an object ( The premise is that this object does not nest other objects ) To cache in Redis in , And every time I read and write the cache , It can be operated Hash A field in .
But the scene is a little more single , Because now many objects are more complex , For example, your product object may contain many attributes , There are also objects . I don't use so many scenes myself .
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-A0ut22O0-1656900930134)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703110402332.png)]](/img/1d/6d2278ce5e01ee0656396166143e87.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-CakMNcxR-1656900930135)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703110537883.png)]](/img/30/fd190ad9313d66d7f36934e09e7185.png)
2.2Hash Basic operation
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-o9LSdF4x-1656900930135)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703111016243.png)]](/img/af/225b6dfede34ad3ae8be5fd0bcb71f.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-AQPftsfz-1656900930135)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703111025910.png)]](/img/7d/3fcd2d65c268d98dc36348a4a517fc.png)
2.3Hash Application scenarios
This is similar Map A structure of , In general, structured data can be used , Like an object ( The premise is that this object does not nest other objects ) To cache in Redis in , And every time I read and write the cache , It can be operated Hash A field in .
2.4Hash matters needing attention
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-ocHdgjdS-1656900930136)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703111043672.png)]](/img/6c/0cccf057090798f955d302cbd084ae.png)
2.5 Application scenarios - E-commerce website shopping cart design and implementation
Tip4:redis Applied to the design of shopping cart data storage
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-asRjPCmB-1656900930136)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703111342453.png)]](/img/26/954f01e5807b8907182e260484c794.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-5ASyTzPg-1656900930136)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703111427072.png)]](/img/0b/042de5aad074fc9c353c937936c800.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-RvuEArMQ-1656900930137)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703111551092.png)]](/img/ca/0f9d90c95dce5a47fc9033eb77c742.png)
2.6 Application scenarios - Rush to buy restricted goods
Tip5:redis It's applied to rush buying , Limited purchase 、 A limited number of coupons will be issued 、 Data storage design of activation code and other services
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-B0HDBUKj-1656900930137)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703111640823.png)]](/img/d4/7027a75cb9b39c69e4fcd845c85733.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-ZWBCtUpP-1656900930137)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703111707438.png)]](/img/a3/fddbbaa197a3a49a75c099e5822902.png)
2.7 Application scenarios -string Store the object (json) And hash Store the object
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-bQfzZvNU-1656900930138)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703111722189.png)]](/img/34/9a4aeb09bc78089991c325f4f01569.png)
3.List
3.1List Introduce
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-aQdpP4ZE-1656900930138)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703203919897.png)]](/img/a2/2c34eeb889d6e93ad311e402a9d1e9.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-6wr4QGY0-1656900930138)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703204228211.png)]](/img/63/572135dc1c39e4f4043170ae2c5c61.png)
3.2List Basic operation
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-faxCcDJk-1656900930138)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703204328900.png)]](/img/52/283768e29e7bdd42c641bb73532762.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-SMcrI5j0-1656900930139)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703204338320.png)]](/img/f4/3fa5c52008ba9756839ecac1ee8f82.png)
3.3List Application scenarios
List There is a sequence table , This one can play a lot of tricks .
For example, through List Store some list data structures , Similar to fan list 、 Comment list of articles and so on .
For example, through lrange command , Read elements in a closed interval , Can be based on List Realize paging query , This is a great feature , be based on Redis Simple high performance paging , You can do things like Weibo that pull down and page continuously , High performance , One page at a time .
For example, we can make a simple message queue , from List Head in , from List Get it out of the ass .
List It is the data structure that we often use in the development process , Hot data, let alone .
1. Message queue :Redis Link list structure of , Blocking queues can be easily implemented , You can use the command composition of left in right out to complete the design of the queue . such as : Producers of data can access Lpush Command to insert data from the left , Multiple data consumers , have access to BRpop Command blocked “ rob ” Data at the end of the list .
2. Application of article list or data page display .
such as , A list of articles from our popular blog sites , When there are more and more users , And every user has their own list of articles , And when there are many articles , All need to be displayed in pages , Consider using Redis A list of , The list is not only ordered, but also supports getting elements according to the scope , It can perfectly solve the paging query function . Greatly improve query efficiency
3.4list matters needing attention
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-eM4XrUYQ-1656900930139)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703204629969.png)]](/img/b2/a7ffa65da06f48fe032e6364677d7d.png)
3.5 Application scenarios - Friends circle like
Tip6:redis Applied to data control with sequence of operations
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-mHXMzL1O-1656900930139)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703213418225.png)]](/img/e5/312a4ed008e6587215a74b970d34d7.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-r2pshRHS-1656900930140)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703213517450.png)]](/img/fc/43e9134064d1d4ec94e109f6409d13.png)
3.6 Application scenarios - Fan following list
Tip7:redis Apply to the latest news display
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-haOmcXoE-1656900930140)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703213548181.png)]](/img/15/734846d438ca50e290f9fb472306f1.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-yC3T0Fo5-1656900930140)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703213902761.png)]](/img/a6/ff562932b7693fc9352ea8d80c029b.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-ZBXakxDM-1656900930140)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220703214042040.png)]](/img/57/a7f87a4a56dbe5cab42e278d37aa22.png)
4.Set
4.1Set Introduce
Set Is an unordered set , It's the kind that will automatically go heavy .
Based on the direct Set Throw in the data that needs to be de duplicated in the system , It's automatic .
Can be based on Set Play together 、 Combine 、 Operation of difference set , Like intersection , We can make a whole intersection of two people's friends list , Let's see who our mutual friends are ? Right .
Anyway, there are many scenes , Because the contrast is fast , It's easy to operate , Two queries one Set Get it done .
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-ijFLTiDY-1656900930141)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704094127135.png)]](/img/0f/92b5b0c367ca7d267bcb9c55f0c88b.png)
4.2Set Basic operation
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-6MAE5mmE-1656900930141)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704094213067.png)]](/img/23/6d742045aadee348cb8b6243ad2e5b.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-zZLY6fPp-1656900930142)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704094227037.png)]](/img/3e/bc0a91b62262308f81e159c559f62b.png)
4.3Set Application scenarios
4.4Set matters needing attention
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-KOx0GTf2-1656900930143)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704094240368.png)]](/img/e5/a46cd372ace852f3a50af61824178d.png)
4.5 Application scenarios - Hot recommendation
Tip8:redis It is applied to random recommendation information retrieval , For example, hot song list recommendation , Hot news recommendation , Hot tourist routes , application APP recommend , Big V Recommendation, etc
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-lNDplCae-1656900930143)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704094335551.png)]](/img/07/e3a36382ebf71d2f03b05f565c6fc6.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Iql69eyJ-1656900930143)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704094459299.png)]](/img/46/3c281f8e68bead6c342e12b4dd2616.png)
4.6 Application scenarios - Association search
Tips 9:redis It is applied to the association search of similar information , Second degree association search , Deep association search
1. Show common concern ( once )
2. Show common friends ( once )
3. By the user A set out , Get friends B A list of your friends' information ( once )
4. By the user A set out , Get friends B List of shopping lists for ( Two degrees )
5. By the user A set out , Get friends B Game recharge list for ( Two degrees )
Tips 10:redis Apply to the consolidation of non duplicate data of the same type 、 Take intersection operation
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-ScNDMqx9-1656900930144)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704094715917.png)]](/img/13/a176e0190d472bcb86f4a06a107fb8.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-RJRp9fFS-1656900930144)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704094726158.png)]](/img/1b/794284fd26c6bb733a688ef5a7a83b.png)

![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-1Gz6yrm9-1656900930144)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704095007179.png)]](/img/6f/39307124f1ade58eabcc55c2b1e80e.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-LL0wSLl7-1656900930145)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704095204819.png)]](/img/f9/6c9fa00523659f88c9377d9b5f6570.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-qPPPkq8F-1656900930145)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704095220956.png)]](/img/8b/75ea53ac7deb50f7b18b8a6f749220.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-q1TQTQWQ-1656900930145)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704095231368.png)]](/img/48/08f8675f16e11781cd0522343c17df.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-1x16IeJg-1656900930146)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704095245396.png)]](/img/71/9ce84c6a1ab1668e7cc7bf125a33f4.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-4Sin0zJI-1656900930146)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704095426037.png)]](/img/bd/ea99ac87c2302f7dbcae3121633f71.png)
4.7 Application scenarios - Website visit to remove duplication
Tip11:redis Fast de duplication for the same type of data
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-gVFcFsBK-1656900930146)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704095457636.png)]](/img/91/2595f14d77c0035a17c5483b882128.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-jvj1pSIQ-1656900930146)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704095520994.png)]](/img/8c/92a254d049b9a5dcdf23b593c1c088.png)
4.9 Application scenarios - Black and white list
Tip12:redis Apply to service settings based on blacklist and whitelist settings
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-hgCV1fUR-1656900930147)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704095547674.png)]](/img/2f/4b71ff5e3ee268b220572665fa6394.png)
5.SortedSet
5.1SortedSet Introduce
Sorted set Is the sort of Set, De duplication but sorting , Give a score when you write it in , Auto sort by score .
The usage scenario of ordered set is similar to that of set , however set Sets are not automatically ordered , and Sorted set You can use scores to sort members , And it's sorted when you insert . So when you need an ordered and non repetitive list of collections , You can choose Sorted set Data structures as options .
1. Ranking List : Orderly collection of classic use scenarios . For example, video websites need to rank videos uploaded by users , The maintenance of the list may be in many ways : According to the time 、 According to the amount of play 、 According to the number of likes, etc .
2. use Sorted Sets To make a weighted queue , For example, ordinary news score by 1, Important news score by 2, Then the worker thread can choose to press score To get the task . Give priority to important tasks .
3. Microblogging Trending , There's a heat value behind it , In front of it is the name
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-D8z7A30Y-1656900930147)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100013303.png)]](/img/7c/dc712310623b24d5553a19a9685d18.png)
5.2SortedSet Basic operation
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-ANOzsQ7Z-1656900930147)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100108674.png)]](/img/bd/fe46afeefd6e31f4db7b089c4eebcc.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-pbnpPdkW-1656900930147)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100127354.png)]](/img/16/e54abf866bdda522a8cc4787871cc9.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-s4bp5w4x-1656900930148)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100202233.png)]](/img/0e/44c05e2bad6ea3673de84d4934314f.png)
5.3SortedSet Application scenarios
5.4SortedSet matters needing attention
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-BjpFJTtw-1656900930148)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100214973.png)]](/img/7a/320f11663a846ac31815742a0baf0a.png)
5.5 Application scenarios - Audition vote
Tip13:redis Applied to the ranking of the counter combination sorting function
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-A4lshvVV-1656900930148)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100242994.png)]](/img/e8/4a1e37b49cddfc4b4a80902e54ab5e.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-ifnhTIRX-1656900930149)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100517593.png)]](https://img-blog.csdnimg.cn/cf91239ce54246d69bdbd125ad2d4e65.png)
5.6 Application scenarios - Membership expires
Tip14:redis It is applicable to scheduled task execution sequence management or task expiration management
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-eajXBara-1656900930149)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100540561.png)]](/img/da/b2db1ddf69d6cb0a6af6dcd4561132.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-SNibiYbI-1656900930149)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100604453.png)]](/img/42/2195821422f850872c04b51139dc84.png)
5.7 Application scenarios - Task weight
Tip15: Apply to immediate tasks / Message queue execution management
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-1T9Tmo6I-1656900930149)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100731862.png)]](/img/40/2bf3445895dd856c7c7652219dc717.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-cQ9QcuV5-1656900930150)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100818104.png)]](/img/34/6cac561c6029cb502bb876595bd6c6.png)
6.redis Business scenario - Voice call
Tip16:redis Service control applied to time limited settlement by time
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-U157QlFP-1656900930150)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100903732.png)]](/img/0c/0c2d58d5ae10c3d5a1e03cfb7acbbc.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-pwzs9CiI-1656900930150)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100925625.png)]](/img/b8/c77bb4bbc093c9096ada2bfcbbe431.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Xvkc2HNw-1656900930150)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704100957912.png)]](/img/4c/24bab41a53d2929e66c126c7eeef35.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-XLFkdbov-1656900930151)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704101053082.png)]](/img/22/dc88898b7b3c68a098daf8123d09e2.png)
7.redis Business scenario - Chat top
Tips17:redis Applied to data manipulation based on time sequence , Instead of focusing on the specific time
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-wJccXA2P-1656900930151)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704101141182.png)]](/img/a9/483274e6ec436c4545c747966a3cc6.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-axvdOkZt-1656900930151)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704101203542.png)]](/img/67/30b538904cd405ec782b014dd0b7fc.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-lqr3ytMU-1656900930151)(C:/Users/86158/AppData/Roaming/Typora/typora-user-images/image-20220704101328321.png)]](/img/28/a3c97b8eee58773b66b4f498ddaff8.png)
8.redis Application scenarios
Tips 1:redis Used to control the database table primary key id, Provide generation strategy for database table primary key , Ensure the uniqueness of the primary key of the database table
Tips 2:redis Control the lifecycle of data , Control business behavior through data failure , Applicable to all operations with time limited control
Tips 3:redis It can be applied to all kinds of structured and unstructured high heat data access acceleration
Tips 4:redis Applied to the design of shopping cart data storage
Tips 5:redis It's applied to rush buying , Limited purchase 、 A limited number of coupons will be issued 、 Data storage design of activation code and other services
Tips 6:redis Applied to data control with sequence of operations
Tips 7:redis Apply to the latest news display
Tips 8:redis It is applied to random recommendation information retrieval , For example, hot song list recommendation , Hot news recommendation , Hot tourist routes , application APP recommend , Big V Recommendation, etc
Tips 9:redis It is applied to the association search of similar information , Second degree association search , Deep association search
Tips 10:redis Apply to the consolidation of non duplicate data of the same type 、 Take intersection operation
Tips 11:redis Fast de duplication for the same type of data
Tips 12:redis Apply to service control based on blacklist and whitelist settings
Tips 13:redis Applied to the ranking of the counter combination sorting function
Tips 14:redis It is applicable to scheduled task execution sequence management or task expiration management
Tips 15:redis Apply to just in time tasks / Message queue execution management
Tips 16:redis Service control applied to settlement by time
Tips 17:redis Applied to data manipulation based on time sequence , Instead of focusing on the specific time
边栏推荐
- Philosophical enlightenment from single point to distributed
- xargs命令的基本用法
- Advanced Computer Network Review(3)——BBR
- [today in history] February 13: the father of transistors was born The 20th anniversary of net; Agile software development manifesto was born
- BN folding and its quantification
- QML control type: Popup
- Post training quantification of bminf
- 注意力机制的一种卷积替代方式
- 如何正确截取字符串(例:应用报错信息截取入库操作)
- Leetcode刷题题解2.1.1
猜你喜欢
随机推荐
[oc foundation framework] - < copy object copy >
UML diagram memory skills
[OC]-<UI入门>--常用控件的学习
什么是MySQL?MySql的学习之路是怎样的
Redis之哨兵模式
BMINF的后训练量化实现
[OC]-<UI入门>--常用控件-UIButton
Redis之cluster集群
[oc]- < getting started with UI> -- learning common controls
LeetCode:394. String decoding
[OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)
Redis之Bitmap
Redis之主从复制
Intel Distiller工具包-量化实现2
AcWing 2456. Notepad
CUDA realizes focal_ loss
在QWidget上实现窗口阻塞
Show slave status \ read in G_ Master_ Log_ POS and relay_ Log_ The (size) relationship of POS
Leetcode刷题题解2.1.1
LeetCode:41. Missing first positive number





![[oc]- < getting started with UI> -- common controls uibutton](/img/4d/f5a62671068b26ef43f1101981c7bb.png)



