当前位置:网站首页>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
边栏推荐
- Raspberry pie + opencv + opencv -- face detection ------- environment construction
- What is a blocking queue? What is the implementation principle of blocking queue? How to use blocking queue to implement producer consumer model?
- Flink case - Kafka, MySQL source
- 【数据库】MySQL单表查询
- Sword finger offer: the median in the data stream (priority queue large top heap small top heap leetcode 295)
- Analysis of POM files
- Leetcode003 -- judge whether an integer is a palindrome number
- Windows remote connection to redis
- 负载均衡简介
- leetcode002--将有符号整数的数字部分反转
猜你喜欢

MySQL -- execution process and principle of a statement
![[WinUI3]编写一个仿Explorer文件管理器](/img/3e/62794f1939da7f36f7a4e9dbf0aa7a.png)
[WinUI3]编写一个仿Explorer文件管理器

AQS源码阅读

Learning Android V from scratch - UI

【数据库】MySQL多表查询(一)
![[WinUI3]編寫一個仿Explorer文件管理器](/img/3e/62794f1939da7f36f7a4e9dbf0aa7a.png)
[WinUI3]編寫一個仿Explorer文件管理器

Shanghai Hangxin technology sharing 𞓜 overview of safety characteristics of acm32 MCU

Learning Android II from scratch - activity

Sword finger offer: the path with a certain value in the binary tree (backtracking)

Spell it! Two A-level universities and six B-level universities have abolished master's degree programs in software engineering!
随机推荐
Leetcode 1547: minimum cost of cutting sticks
redis和mysql区别
Jetpack -- lifecycle usage and source code analysis
Repair of self calibration SPC failure of Tektronix oscilloscope dpo3054
What is a data island? Why is there still a data island in 2022?
General enumeration constant class
使用model.load_state_dict()时,出现AttributeError: ‘str‘ object has no attribute ‘copy‘
Teach you how to build the ruoyi system by Tencent cloud
Sword finger offer: push in and pop-up sequence of stack
【数据库】MySQL基本操作(基操~)
【数据库】MySQL多表查询(一)
Spark case - wordcount
Innovation training (XI) airline ticket crawling company information
What is the meaning of load balancing
Progress of innovation training (III)
Leetcode008 -- implement strstr() function
[winui3] write an imitation Explorer file manager
Spark small case - RDD, spark SQL
View analysis of scenic spots in ArcGIS
COM in wine (2) -- basic code analysis