当前位置:网站首页>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
边栏推荐
- An error is reported in the process of using gbase 8C database: 80000305, host IPS long to different cluster. How to solve it?
- CDGA|数据治理不得不坚持的六个原则
- 如何让你的产品越贵越好卖
- 2048游戏逻辑
- MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
- 《看完就懂系列》15个方法教你玩转字符串
- Redis如何实现多可用区?
- FreeRTOS 中 RISC-V-Qemu-virt_GCC 的调度时机
- Dynamic SQL of ibatis
- PHP中Array的hash函数实现
猜你喜欢

COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics

Intelligent metal detector based on openharmony

Oneforall installation and use
![[crawler] bugs encountered by wasm](/img/29/6782bda4c149b7b2b334238936e211.png)
[crawler] bugs encountered by wasm

Basics - rest style development

11.(地图数据篇)OSM数据如何下载使用

【Office】Excel中IF函数的8种用法

go语言学习笔记-分析第一个程序

COMSOL -- three-dimensional graphics random drawing -- rotation

Advanced technology management - what is the physical, mental and mental strength of managers
随机推荐
Four departments: from now on to the end of October, carry out the "100 day action" on gas safety
An error is reported in the process of using gbase 8C database: 80000305, host IPS long to different cluster. How to solve it?
Home office things community essay
MFC pet store information management system
Go language learning notes - first acquaintance with go language
[leetcode] wild card matching
Implementation of array hash function in PHP
中非 钻石副石怎么镶嵌,才能既安全又好看?
POJ 3176-Cow Bowling(DP||记忆化搜索)
MySQL 巨坑:update 更新慎用影响行数做判断!!!
Oneforall installation and use
Evolution of multi-objective sorting model for classified tab commodity flow
爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架
spark调优(一):从hql转向代码
C language current savings account management system
Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things
技术管理进阶——什么是管理者之体力、脑力、心力
C # to obtain the filtered or sorted data of the GridView table in devaexpress
How did the situation that NFT trading market mainly uses eth standard for trading come into being?
11.(地图数据篇)OSM数据如何下载使用