当前位置:网站首页>Hash tag usage in redis cluster
Hash tag usage in redis cluster
2022-07-05 11:44:00 【We've been on the road】
hash tag be used for redis In the cluster . It is realized in key Add a {}, for example test{1}. Use hash tag After that, the client is calculating key Of crc16 when , Only calculate {} Data in the . If not used hash tag, The client will be responsible for the whole key Conduct crc16 Calculation . So let's do that hash tag Use .
-
127.0.0.1:6380> cluster keyslot user:
case
-
(
integer) 9491
-
127.0.0.1:6380> cluster keyslot user:
case{1}
-
(
integer) 9842
-
127.0.0.1:6380> cluster keyslot user:info
-
(
integer) 15429
-
127.0.0.1:6380> cluster keyslot user:info{1}
-
(
integer) 9842
-
-
-
You can see through the above code , Don't use
hash tag Corresponding
hash slot Is different , After use, it will correspond to a
hash slot in
advantage :
hash tag The main function is to store a fixed feature data on an instance , Avoid querying instances in the cluster one by one . For example, user information and user order quantity are stored in an instance for subsequent display statistics .
-
Will the user id by
1 The relevant information of is stored in
6380 example
-
127.0.0.1:6380> set
user:info{
1} essential information
-
OK
-
127.0.0.1:6380> set
user:order{
1}
2
-
OK
-
127.0.0.1:6380> keys *
-
1)
"user:order{1}"
-
2)
"user:info{1}"
shortcoming :
It may cause the data to be concentrated in one instance , Cause data skew , For example, the user 1-10000 The data of is stored in an instance .
-
If only
1-
10000 Of users have order information , Then it is equivalent to that all information is stored in
6380 In this instance
-
127.0.0.1:6380> set
user:
1
:order{
1-
10000}
2
-
OK
-
127.0.0.1:6380> set
user:
2
:order{
1-
10000}
2
-
OK
-
127.0.0.1:6380> set
user:
3
:order{
1-
10000}
2
-
OK
边栏推荐
- redis 集群模式原理
- SET XACT_ABORT ON
- 7 themes and 9 technology masters! Dragon Dragon lecture hall hard core live broadcast preview in July, see you tomorrow
- 2048 game logic
- iTOP-3568开发板NPU使用安装RKNN Toolkit Lite2
- How did the situation that NFT trading market mainly uses eth standard for trading come into being?
- 871. Minimum Number of Refueling Stops
- [LeetCode] Wildcard Matching 外卡匹配
- Yolov5 target detection neural network -- calculation principle of loss function
- ZCMU--1390: 队列问题(1)
猜你喜欢
随机推荐
【yolov5.yaml解析】
c#操作xml文件
12.(地图数据篇)cesium城市建筑物贴图
【主流Nivida显卡深度学习/强化学习/AI算力汇总】
中非 钻石副石怎么镶嵌,才能既安全又好看?
13. (map data) conversion between Baidu coordinate (bd09), national survey of China coordinate (Mars coordinate, gcj02), and WGS84 coordinate system
Dynamic SQL of ibatis
Proof of the thinking of Hanoi Tower problem
yolov5目標檢測神經網絡——損失函數計算原理
无线WIFI学习型8路发射遥控模块
【TFLite, ONNX, CoreML, TensorRT Export】
程序员内卷和保持行业竞争力
11.(地图数据篇)OSM数据如何下载使用
SET XACT_ ABORT ON
[office] eight usages of if function in Excel
2048游戏逻辑
[singleshotmultiboxdetector (SSD, single step multi frame target detection)]
871. Minimum Number of Refueling Stops
Guys, I tested three threads to write to three MySQL tables at the same time. Each thread writes 100000 pieces of data respectively, using F
redis 集群模式原理