当前位置:网站首页>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
边栏推荐
- The art of communication III: Listening between people
- How can China Africa diamond accessory stones be inlaid to be safe and beautiful?
- MFC pet store information management system
- 无密码身份验证如何保障用户隐私安全?
- Solve the problem of slow access to foreign public static resources
- 如何让你的产品越贵越好卖
- Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment
- Unity xlua monoproxy mono proxy class
- pytorch训练进程被中断了
- How to make full-color LED display more energy-saving and environmental protection
猜你喜欢
COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics
[advertising system] parameter server distributed training
[advertising system] incremental training & feature access / feature elimination
OneForAll安装使用
COMSOL -- 3D casual painting -- sweeping
Three paradigms of database
The ninth Operation Committee meeting of dragon lizard community was successfully held
11.(地图数据篇)OSM数据如何下载使用
技术管理进阶——什么是管理者之体力、脑力、心力
How can China Africa diamond accessory stones be inlaid to be safe and beautiful?
随机推荐
Evolution of multi-objective sorting model for classified tab commodity flow
Pytorch training process was interrupted
基础篇——基础项目解析
AUTOCAD——遮罩命令、如何使用CAD对图纸进行局部放大
spark调优(一):从hql转向代码
Basic part - basic project analysis
如何通俗理解超级浏览器?可以用于哪些场景?有哪些品牌?
Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework
11.(地图数据篇)OSM数据如何下载使用
Startup process of uboot:
阻止瀏覽器後退操作
TSQL – identity column, guid, sequence
解决readObjectStart: expect { or n, but found N, error found in #1 byte of ...||..., bigger context ..
使用GBase 8c数据库过程中报错:80000305,Host ips belong to different cluster ,怎么解决?
Summary of thread and thread synchronization under window
C # to obtain the filtered or sorted data of the GridView table in devaexpress
Unity xlua monoproxy mono proxy class
管理多个Instagram帐户防关联小技巧大分享
Characteristics and electrical parameters of DDR4
Codeforces Round #804 (Div. 2)