当前位置:网站首页>What are the redis data types
What are the redis data types
2022-04-23 04:52:00 【xmh-sxh-1314】
String( character string )
string yes redis Most basic types , You can understand that Memcached As like as two peas , One key Corresponding to one value.
string Type is binary safe . intend redis Of string Can contain any data . such as jpg Picture or serialized object .
string The type is Redis Basic data types ,string The maximum value of type can store 512MB.
Common commands :set、get、decr、incr、mget etc. .
Be careful : Maximum storage of one key 512MB.
Hash( Hash )
Redis hash It's a key value (key=>value) The collection ; It's a string Type of field and value Mapping table ,hash Ideal for storing objects .
Every hash Can be stored 232 -1 Key value pair (40 More than ).
Common commands :hget、hset、hgetall etc. .
Application scenarios : Store some structured data , For example, the user's nickname 、 Age 、 Gender 、 Integral, etc. , Store a user information object data .
List( list )
Redis List is a simple list of strings , Sort by insertion order . You can add an element to the head of the list ( On the left ) Or tail ( On the right ).
list Types are often used for message queuing services , To complete the message exchange between multiple programs .
Common commands :lpush、rpush、lpop、rpop、lrange etc. .
List can be stored at most 232 - 1 Elements (4294967295, Each list can be stored 40 More than ).
Set( aggregate )
Redis Of Set yes string Unordered collection of type . 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.
Collections are implemented through hash tables , So add the , Delete , The complexity of searching is O(1).
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 .
Common commands :sadd、spop、smembers、sunion etc. .
The maximum number of members in the collection is 232 - 1(4294967295, Each collection can store 40 More than 100 million members ).
zset(sorted set: Ordered set )
Redis zset and set The same is true. string Collection of type elements , And duplicate members are not allowed .
The difference is that each element is associated with a double Score of type .redis It's the scores that sort the members of a collection from small to large .
zset Members of are unique , But fractions (score) But it can be repeated .
sorted set It 's inserted in order , That is, automatic sorting .
Common commands :zadd、zrange、zrem、zcard etc. .
When you need an ordered and non repetitive list of collections , Then you can choose sorted set data structure .
Application, for example, :
(1) For example, store the scores of the whole class , Its collection value It can be the student number of a classmate , and score It can be achievement .
(2) Leaderboard app , List by score topN Users, etc .
版权声明
本文为[xmh-sxh-1314]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230446013455.html
边栏推荐
- Innovation training (VI) routing
- Wechat payment function
- Record the blind injection script
- Repair of self calibration SPC failure of Tektronix oscilloscope dpo3054
- Detailed explanation of the differences between TCP and UDP
- C language: Advanced pointer
- Leetcode009 -- search the target value in the array with binary search
- Other problems encountered in debugging fingerprints
- Set Chrome browser background to eye protection (eye escort / darkreader plug-in)
- Innovation training (V) configuration information
猜你喜欢

COM in wine (2) -- basic code analysis

CLion+OpenCV identify ID number - detect ID number

Innovation training (V) configuration information

C language: spoof games

Eight misunderstandings that should be avoided in data visualization

Wechat payment function

持续集成(CI)/持续交付(CD)如何彻底改变自动化测试

【数据库】MySQL单表查询

Practice and exploration of knowledge map visualization technology in meituan

Innovation training (VI) routing
随机推荐
泰克示波器DPO3054自校准SPC失败维修
Recommended scheme of national manufactured electronic components for intelligent electronic scales
Jetpack -- lifecycle usage and source code analysis
leetcode008--实现strStr()函数
Spark FAQ sorting - must see before interview
L2-011 玩转二叉树(建树+BFS)
Special topic of data intensive application system design
Flink case - Kafka, MySQL source
拼了!两所A级大学,六所B级大学,纷纷撤销软件工程硕士点!
selenium模式下切换窗口,抓取数据的实现
Analysis of POM files
[WinUI3]编写一个仿Explorer文件管理器
Innovation training (IV) preliminary preparation - server
How can continuous integration (CI) / continuous delivery (CD) revolutionize automated testing
Leetcode002 -- inverts the numeric portion of a signed integer
Leetcode005 -- delete duplicate elements in the array in place
List remove an element
Informatics Aosai yibentong 1212: letters | openjudge 2.5 156: Letters
ApplicationContext injection bean
信息学奥赛一本通 1212:LETTERS | OpenJudge 2.5 156:LETTERS