当前位置:网站首页>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
边栏推荐
- 负载均衡简介
- leetcode002--将有符号整数的数字部分反转
- Leetcode004 -- Roman numeral to integer
- 使用model.load_state_dict()时,出现AttributeError: ‘str‘ object has no attribute ‘copy‘
- Sword finger offer: the path with a certain value in the binary tree (backtracking)
- KVM error: Failed to connect socket to ‘/var/run/libvirt/libvirt-sock‘
- Open the past and let's start over.
- What is the meaning of load balancing
- What is a data island? Why is there still a data island in 2022?
- Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
猜你喜欢
Thoughts on a small program
Eight misunderstandings that should be avoided in data visualization
Wechat payment function
Programmers complain: I really can't live with a salary of 12000. Netizen: how can I say 3000
Recommended scheme for national production of electronic components of wireless keyboard
【数据库】MySQL基本操作(基操~)
简单的拖拽物体到物品栏
Excel protects worksheets and workbooks from damage
Innovation training (VI) routing
DIY 一个 Excel 版的子网计算器
随机推荐
leetcode007--判断字符串中的括号是否匹配
Programmers complain: I really can't live with a salary of 12000. Netizen: how can I say 3000
Learning Android from scratch -- Introduction
Better way to read configuration files than properties
Learning Android from scratch -- baseactivity and activitycollector
Unity攝像頭跟隨鼠標旋轉
DIY 一个 Excel 版的子网计算器
[2021] Spatio-Temporal Graph Contrastive Learning
redis数据类型有哪些
MySQL - data read / write separation, multi instance
Innovation training (V) mid term inspection
Informatics Aosai yibentong 1212: letters | openjudge 2.5 156: Letters
Flink's important basics
Record the blind injection script
Pixel mobile phone brick rescue tutorial
敏捷实践 | 提高小组可预测性的敏捷指标
Druid -- JDBC tool class case
Excel protects worksheets and workbooks from damage
Innovative practice of short video content understanding and generation technology in meituan
leetcode002--将有符号整数的数字部分反转