当前位置:网站首页>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
边栏推荐
- Prevent browser backward operation
- In the last process before the use of the risk control model, 80% of children's shoes are trampled here
- Spark Tuning (I): from HQL to code
- C#实现WinForm DataGridView控件支持叠加数据绑定
- Pytorch training process was interrupted
- DDoS attack principle, the phenomenon of being attacked by DDoS
- 阻止瀏覽器後退操作
- How to understand super browser? What scenarios can it be used in? What brands are there?
- 解决readObjectStart: expect { or n, but found N, error found in #1 byte of ...||..., bigger context ..
- How to protect user privacy without password authentication?
猜你喜欢
[crawler] Charles unknown error
Pytorch training process was interrupted
How to introduce devsecops into enterprises?
CDGA|数据治理不得不坚持的六个原则
Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things
NFT 交易市场主要使用 ETH 本位进行交易的局面是如何形成的?
Characteristics and electrical parameters of DDR4
7 themes and 9 technology masters! Dragon Dragon lecture hall hard core live broadcast preview in July, see you tomorrow
中非 钻石副石怎么镶嵌,才能既安全又好看?
如何让你的产品越贵越好卖
随机推荐
Stop saying that microservices can solve all problems!
跨境电商是啥意思?主要是做什么的?业务模式有哪些?
Summary of websites of app stores / APP markets
COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics
基础篇——REST风格开发
Four departments: from now on to the end of October, carry out the "100 day action" on gas safety
1.php的laravel创建项目
POJ 3176 cow bowling (DP | memory search)
Solve readobjectstart: expect {or N, but found n, error found in 1 byte of
[office] eight usages of if function in Excel
汉诺塔问题思路的证明
R3live series learning (IV) r2live source code reading (2)
FreeRTOS 中 RISC-V-Qemu-virt_GCC 的调度时机
如何通俗理解超级浏览器?可以用于哪些场景?有哪些品牌?
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
COMSOL -- three-dimensional graphics random drawing -- rotation
Empêcher le navigateur de reculer
Dspic33ep clock initialization program
阻止浏览器后退操作
COMSOL--建立几何模型---二维图形的建立