当前位置:网站首页>redis集群中hash tag 使用
redis集群中hash tag 使用
2022-07-05 11:31:00 【我们一直在路上】
hash tag用于redis集群中。其实现方式为在key中加个{},例如test{1}。使用hash tag后客户端在计算key的crc16时,只计算{}中数据。如果没使用hash tag,客户端会对整个key进行crc16计算。下面演示下hash tag使用。
-
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
-
-
-
通过以上代码可以看到,不使用
hash tag 对应的
hash slot是不同的,使用后则会对应到一个
hash slot中
优点:
hash tag主要作用是将某一固定特征数据存储到一台实例上,避免逐个查询集群中实例。例如将用户信息与用户订单数量存储到一个实例用于后续展示统计。
-
将用户id为
1的相关信息存储在
6380实例
-
127.0.0.1:6380> set
user:info{
1} 基本信息
-
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}"
缺点:
可能会导致数据集中在一个实例中,造成数据倾斜,例如将用户1-10000的数据存储在一个实例中。
-
如果只有
1-
10000的用户有订单信息,那么相当于所有信息都存储在了
6380这台实例中
-
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
边栏推荐
- MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
- 阻止瀏覽器後退操作
- How does redis implement multiple zones?
- Startup process of uboot:
- Install esxi 6.0 interactively
- FFmpeg调用avformat_open_input时返回错误 -22(Invalid argument)
- Shell script file traversal STR to array string splicing
- 871. Minimum Number of Refueling Stops
- Prevent browser backward operation
- Web API configuration custom route
猜你喜欢

CDGA|数据治理不得不坚持的六个原则

【爬虫】wasm遇到的bug

COMSOL--建立几何模型---二维图形的建立

Idea set the number of open file windows

Summary of thread and thread synchronization under window

Huawei equipment configures channel switching services without interruption

idea设置打开文件窗口个数

MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!

Modulenotfounderror: no module named 'scratch' ultimate solution

How did the situation that NFT trading market mainly uses eth standard for trading come into being?
随机推荐
阻止瀏覽器後退操作
Harbor镜像仓库搭建
Unity xlua monoproxy mono proxy class
AUTOCAD——遮罩命令、如何使用CAD对图纸进行局部放大
POJ 3176 cow bowling (DP | memory search)
Startup process of uboot:
Ffmpeg calls avformat_ open_ Error -22 returned during input (invalid argument)
871. Minimum Number of Refueling Stops
COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics
Dspic33ep clock initialization program
COMSOL--三维随便画--扫掠
Four departments: from now on to the end of October, carry out the "100 day action" on gas safety
Advanced technology management - what is the physical, mental and mental strength of managers
边缘计算如何与物联网结合在一起?
uboot的启动流程:
C#实现WinForm DataGridView控件支持叠加数据绑定
Question and answer 45: application of performance probe monitoring principle node JS probe
Is it difficult to apply for a job after graduation? "Hundreds of days and tens of millions" online recruitment activities to solve your problems
[Oracle] use DataGrid to connect to Oracle Database
C language current savings account management system