当前位置:网站首页>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
边栏推荐
- Mongdb learning notes
- sql server char nchar varchar和nvarchar的区别
- Easyocr character recognition
- 手写promise与async await
- Type declaration of all DOM elements in TS
- CPU设计实战-第四章实践任务二用阻塞技术解决相关引发的冲突
- qt creater断点调试程序详解
- Coding devsecops helps financial enterprises run out of digital acceleration
- CODING DevSecOps 助力金融企业跑出数字加速度
- B站做短视频,学抖音死,学YouTube生?
猜你喜欢
FR练习题目---综合题
想进阿里必须啃透的12道MySQL面试题
Creation and use of thymeleaf template
Ctfshow web entry explosion
Two Bi development, more than 3000 reports? How to do it?
There is a powerful and good-looking language bird editor, which is better than typora and developed by Alibaba
超越PaLM!北大硕士提出DiVeRSe,全面刷新NLP推理排行榜
[detailed explanation of Huawei machine test] character statistics and rearrangement
Photoshop plug-in action related concepts actionlist actiondescriptor actionlist action execution load call delete PS plug-in development
Interview shock 62: what are the precautions for group by?
随机推荐
黑马程序员-软件测试-10阶段2-linux和数据库-44-57为什么学习数据库,数据库分类关系型数据库的说明Navicat操作数据的说明,Navicat操作数据库连接说明,Navicat的基本使用,
数据库学习——数据库安全性
PostgreSQL 13 installation
[12 classic written questions of array and advanced pointer] these questions meet all your illusions about array and pointer, come on!
STM32+BH1750光敏传感器获取光照强度
Select sort and bubble sort
Behind the ultra clear image quality of NBA Live Broadcast: an in-depth interpretation of Alibaba cloud video cloud "narrowband HD 2.0" technology
729. My schedule I: "simulation" & "line segment tree (dynamic open point) &" block + bit operation (bucket Division) "
机器学习框架简述
PyTorch二分类时BCELoss,CrossEntropyLoss,Sigmoid等的选择和使用
【NVMe2.0b 14-9】NVMe SR-IOV
计算中间件 Apache Linkis参数解读
浅谈Dataset和Dataloader在加载数据时如何调用到__getitem__()函数
Mongdb learning notes
FR练习题目---简单题
No one consults when doing research and does not communicate with students. UNC assistant professor has a two-year history of teaching struggle
[recruitment position] Software Engineer (full stack) - public safety direction
Ctfshow web entry explosion
超级哇塞的快排,你值得学会!
Jmeter性能测试:ServerAgent资源监控