当前位置:网站首页>Common redis data types and application scenarios
Common redis data types and application scenarios
2022-07-05 15:04:00 【Back end regular developers】
List of articles
Five common data types : character string string, list list, hash hash, aggregate set, Ordered set sorted set
1. character string string:
The string type is Redis The most basic data storage type in , It's a sequence of bytes , He was in Redis Is binary safe , This means that the type can accept data in any format , It's standard key-value, It's usually used to store strings , Integers and floating point numbers .Value The maximum data length that can be accommodated is 512MB
Application scenarios : A very common scenario is used to count the number of website visits , Number of people currently online, etc .incr command (++ operation )
2. list list:
Redis The list allows users to push or pop elements from both ends of the sequence , A list is an ordered, repeatable sequence of multiple string values , It's a list structure , So the time complexity of adding elements to both ends of the list is 0(1), The closer you get to both ends, the faster . This means even a list of tens of millions of elements , To obtain the head or tail of 10 Records are also very fast .List The maximum number of elements that can be contained in is 4294967295.
Application scenarios :1. The latest news leaderboard .2. Message queue , To complete the message exchange between multiple programs . It can be used push The operation will cause the task to exist list in ( producer ), Then the thread is in use pop The operation takes the task out for execution
3. hash hash:
Redis Hash in can be regarded as having String key and String value Of map Containers , Multiple key-value Store in a key in . every last Hash Can be stored 4294967295 Key value pairs .
Application scenarios : Such as storage 、 Read 、 Modify user properties (name,age,pwd etc. )
4. aggregate set:
Redis The set of is unordered and unrepeatable , Just like the list , When performing insert and delete and determining whether an element exists , Efficiency is very high . The biggest advantage of a set is that it can perform intersection, union and subtraction operations .Set The maximum number of elements that can be included is 4294967295.
Application scenarios :1. Use intersection to find common friends .2. Using uniqueness , You can count all the independent websites you visit IP.3. Friends recommend according to tag Find the intersection , Greater than one threshold( Of the critical value ) You can recommend .
5. Ordered set sorted set:
and set It's like , It's a collection of strings , Do not allow duplicate members to appear in a set in . The difference between them is that each member of the ordered set will have a score (score) Associated with it ,Redis It's the scores that sort the members of a collection from small to large . Although the members in the ordered set must be guards , But the score (score) But it can be repeated .
Application scenarios : Can be used for a large online game ranking , Whenever a player's score changes , It can be executed zadd Update player scores (score), After that, we passed zrange Get some points top ten User information for .
Last , There's another one right key General operation of , All data types can be used
Reprinted from :https://blog.csdn.net/m0_54425879/article/details/116783792
边栏推荐
- Crud de MySQL
- Interview shock 62: what are the precautions for group by?
- Long list optimized virtual scrolling
- 一键更改多个文件名字
- 超越PaLM!北大硕士提出DiVeRSe,全面刷新NLP推理排行榜
- 可转债打新在哪里操作开户是更安全可靠的呢
- JS bright blind your eyes date selector
- 【数组和进阶指针经典笔试题12道】这些题,满足你对数组和指针的所有幻想,come on !
- ICML 2022 | 探索语言模型的最佳架构和训练方法
- Ctfshow web entry information collection
猜你喜欢
Interpretation of Apache linkage parameters in computing middleware
两个BI开发,3000多张报表?如何做的到?
选择排序和冒泡排序
Ctfshow web entry command execution
Stop B makes short videos, learns Tiktok to die, learns YouTube to live?
MySQL----函数
DVWA range clearance tutorial
安装配置Jenkins
Drive brushless DC motor based on Ti drv10970
729. My schedule I: "simulation" & "line segment tree (dynamic open point) &" block + bit operation (bucket Division) "
随机推荐
Talk about your understanding of microservices (PHP interview theory question)
IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
Can I pass the PMP Exam in 20 days?
B站做短视频,学抖音死,学YouTube生?
DVWA range clearance tutorial
Live broadcast preview | how to implement Devops with automatic tools (welfare at the end of the article)
Drive brushless DC motor based on Ti drv10970
两个BI开发,3000多张报表?如何做的到?
Magic methods and usage in PHP (PHP interview theory questions)
CPU设计相关笔记
How can I quickly check whether there is an error after FreeSurfer runs Recon all—— Core command tail redirection
想进阿里必须啃透的12道MySQL面试题
百亿按摩仪蓝海,难出巨头
超级哇塞的快排,你值得学会!
qt creater断点调试程序详解
"Sequelae" of the withdrawal of community group purchase from the city
Your childhood happiness was contracted by it
用 Go 跑的更快:使用 Golang 为机器学习服务
Where is the operation of convertible bond renewal? Is it safer and more reliable to open an account
想问下大家伙,有无是从腾讯云MYSQL同步到其他地方的呀?腾讯云MySQL存到COS上的binlog