当前位置:网站首页>Details of redis core data structure & new features of redis 6
Details of redis core data structure & new features of redis 6
2022-07-07 13:57:00 【bingtanghulu_ six】
Catalog
1.list
redis stay redisDB There is a k-V structure , Stored in dictionary dict in ,dict Contains two hashTable structure , Exists as an array , among list Is an ordered data structure , Use double ended linked list quicklist and ziplist As an underlying implementation .
[[email protected] ~]# cd /usr/local/redis-6.2.7
[[email protected] redis-6.2.7]# src/redis-server redis.conf
[[email protected] redis-6.2.7]# src/redis-cli
127.0.0.1:6379> lpush a-list a b c
(integer) 3
127.0.0.1:6379> rpush a-list e f g
(integer) 6
127.0.0.1:6379> rpush a-list e 1100 f g
(integer) 10
127.0.0.1:6379> type a-list
list
127.0.0.1:6379> object encoding a-list
"quicklist"

list The data structure is as follows :

2.hash
hash Use when the field is small ziplist Storage , When it is relatively large hashtable Storage , The following figure shows object encoding key Code by ziplist Change to hashtable Scene .
127.0.0.1:6379> hset a-hash name caiji age 35 f1 v1 f2 v2 f3 v3
(integer) 5
127.0.0.1:6379> hgetall a-hash
1) "name"
2) "caiji"
3) "age"
4) "35"
5) "f1"
6) "v1"
7) "f2"
8) "v2"
9) "f3"
10) "v3"
127.0.0.1:6379> type a-hash
hash
127.0.0.1:6379> object encoding a-hash
"ziplist"
127.0.0.1:6379> hset a-hash f4 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
(integer) 1
127.0.0.1:6379> hgetall a-hash
1) "f1"
2) "v1"
3) "name"
4) "caiji"
5) "f2"
6) "v2"
7) "age"
8) "35"
9) "f3"
10) "v3"
11) "f4"
12) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
127.0.0.1:6379> type a-hash
hash
127.0.0.1:6379> object encoding a-hash
"hashtable"hash The data structure is as follows , Can be set by redis.conf Configuration file configuration ziplist and hashtable The storage range of
Interview questions :string and hash Selection and advantages and disadvantages

3.Set
Set For unordered automatic de duplication data types , It is ordered when all are stored in integer , Bottom use intset data structure , When stored in strings, it is unordered , Use hashtable Storage .

127.0.0.1:6379> sadd a-set 1 2 3 5 10 9 4 4 4
(integer) 7
127.0.0.1:6379> smembers a-set
1) "1"
2) "2"
3) "3"
4) "4"
5) "5"
6) "9"
7) "10"
127.0.0.1:6379> type a-set
set
127.0.0.1:6379> object encoding a-set
"intset"
127.0.0.1:6379> sadd a-set a
(integer) 1
127.0.0.1:6379> smembers a-set
1) "a"
2) "3"
3) "10"
4) "9"
5) "4"
6) "2"
7) "5"
8) "1"
127.0.0.1:6379> type a-set
set
127.0.0.1:6379> object encoding a-set
"hashtable"
intset The data structure is as follows , There are three elements .

4.Zset
skiplist principle , Use half to find , The index method forms an index tree to find data , The first K Layer index number =n/2^k.

127.0.0.1:6379> zadd a-zset 100 a 200 b 150 c
(integer) 3
127.0.0.1:6379> zrange a-zset 0 -1 withscores
1) "a"
2) "100"
3) "c"
4) "150"
5) "b"
6) "200"
127.0.0.1:6379> type a-zset
zset
127.0.0.1:6379> object encoding a-zset
"ziplist"

5.GeoHash
GeoHash It's an algorithm plus zset Realized
help @geo


geohash Underlying implementation , The longitude and latitude coding rules are as follows .gethash Only fuzzy ranges can be sent , No specific longitude and latitude will be sent , It is suitable for scenes with low accuracy



6. Interview FAQs
1. redis The multithreading model of , stay redis.conf Mid search thread-I/O There are detailed notes
redis Execution process :read- analysis resp agreement - Carry out orders - write in
Multithreading is off by default , You can set redis.conf in io-thread Parameters , Here's the picture
Configured with io-threads-do-reads Parameters later others I/O Threads can also perform read and write tasks
边栏推荐
- The meaning of variables starting with underscores in PHP
- 实现IP地址归属地显示功能、号码归属地查询
- ES日志报错赏析-Limit of total fields
- Error lnk2019: unresolved external symbol
- xshell连接服务器把密钥登陆改为密码登陆
- Navicat run SQL file import data incomplete or import failed
- 室內ROS機器人導航調試記錄(膨脹半徑的選取經驗)
- Huawei image address
- Realize the IP address home display function and number home query
- Learning breakout 2 - about effective learning methods
猜你喜欢

高等數學---第八章多元函數微分學1

Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1

Ways to improve the performance of raspberry pie

如何让join跑得更快?

Evolution of customer service hotline of dewu

2022-7-7 Leetcode 844.比较含退格的字符串

2022-7-6 Leetcode27. Remove the element - I haven't done the problem for a long time. It's such an embarrassing day for double pointers

118. 杨辉三角

社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生

Final review notes of single chip microcomputer principle
随机推荐
ES日志报错赏析-Limit of total fields
Deep understanding of array related problems in C language
室内ROS机器人导航调试记录(膨胀半径的选取经验)
Vmware共享主机的有线网络IP地址
Laravel form builder uses
[1] ROS2基础知识-操作命令总结版
Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
JS function returns multiple values
1、深拷贝 2、call apply bind 3、for of for in 区别
Attribute keywords aliases, calculated, cardinality, ClientName
Xshell connection server changes key login to password login
最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
Laravel5 call to undefined function openssl cipher iv length() 报错 PHP7开启OpenSSL扩展失败
ROS机器人更换新雷达需要重新配置哪些参数
2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置
Redis can only cache? Too out!
[1] Basic knowledge of ros2 - summary version of operation commands
Custom thread pool rejection policy
.net core 关于redis的pipeline以及事务
Error lnk2019: unresolved external symbol