当前位置:网站首页>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
边栏推荐
- 基础篇——REST风格开发
- 查看多台机器所有进程
- 7 大主题、9 位技术大咖!龙蜥大讲堂7月硬核直播预告抢先看,明天见
- 2048 game logic
- Three suggestions for purchasing small spacing LED display
- SET XACT_ ABORT ON
- [office] eight usages of if function in Excel
- Detailed explanation of MATLAB cov function
- Home office things community essay
- [Oracle] use DataGrid to connect to Oracle Database
猜你喜欢

In the last process before the use of the risk control model, 80% of children's shoes are trampled here

7 themes and 9 technology masters! Dragon Dragon lecture hall hard core live broadcast preview in July, see you tomorrow

12.(地图数据篇)cesium城市建筑物贴图

7 大主题、9 位技术大咖!龙蜥大讲堂7月硬核直播预告抢先看,明天见

Detailed explanation of DDR4 hardware schematic design
![[crawler] Charles unknown error](/img/82/c36b225d0502f67cd04225f39de145.png)
[crawler] Charles unknown error

Detailed explanation of MATLAB cov function

How to make full-color LED display more energy-saving and environmental protection

【爬虫】wasm遇到的bug

idea设置打开文件窗口个数
随机推荐
spark调优(一):从hql转向代码
Huawei equipment configures channel switching services without interruption
[SWT component] content scrolledcomposite
Is it difficult to apply for a job after graduation? "Hundreds of days and tens of millions" online recruitment activities to solve your problems
IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
技术管理进阶——什么是管理者之体力、脑力、心力
DDoS attack principle, the phenomenon of being attacked by DDoS
SET XACT_ ABORT ON
7 大主题、9 位技术大咖!龙蜥大讲堂7月硬核直播预告抢先看,明天见
Intelligent metal detector based on openharmony
7.2 daily study 4
How can China Africa diamond accessory stones be inlaid to be safe and beautiful?
Cron expression (seven subexpressions)
Shell script file traversal STR to array string splicing
An error is reported in the process of using gbase 8C database: 80000305, host IPS long to different cluster. How to solve it?
管理多个Instagram帐户防关联小技巧大分享
Golang application topic - channel
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
Idea set the number of open file windows
How to introduce devsecops into enterprises?