当前位置:网站首页>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
边栏推荐
- In the last process before the use of the risk control model, 80% of children's shoes are trampled here
- DDoS attack principle, the phenomenon of being attacked by DDoS
- 项目总结笔记系列 wsTax KT Session2 代码分析
- How can edge computing be combined with the Internet of things?
- Implementation of array hash function in PHP
- Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things
- Web API配置自定义路由
- 无密码身份验证如何保障用户隐私安全?
- Cron表达式(七子表达式)
- I used Kaitian platform to build an urban epidemic prevention policy inquiry system [Kaitian apaas battle]
猜你喜欢

Oneforall installation and use

COMSOL--三维图形的建立

Stop saying that microservices can solve all problems!

7.2 daily study 4

中非 钻石副石怎么镶嵌,才能既安全又好看?

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

Harbor image warehouse construction

紫光展锐全球首个5G R17 IoT NTN卫星物联网上星实测完成

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

How to introduce devsecops into enterprises?
随机推荐
FFmpeg调用avformat_open_input时返回错误 -22(Invalid argument)
An error is reported in the process of using gbase 8C database: 80000305, host IPS long to different cluster. How to solve it?
7.2每日学习4
Open3D 网格(曲面)赋色
PHP中Array的hash函数实现
Detailed explanation of DDR4 hardware schematic design
阻止瀏覽器後退操作
Solve readobjectstart: expect {or N, but found n, error found in 1 byte of
Evolution of multi-objective sorting model for classified tab commodity flow
shell脚本文件遍历 str转数组 字符串拼接
龙蜥社区第九次运营委员会会议顺利召开
How can edge computing be combined with the Internet of things?
技术分享 | 常见接口协议解析
Mysql统计技巧:ON DUPLICATE KEY UPDATE用法
Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
Sklearn model sorting
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
[crawler] Charles unknown error
Implementation of array hash function in PHP