Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
spring-boot-starter-dsp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
shenjiaqing
spring-boot-starter-dsp
Commits
3b0342a7
Commit
3b0342a7
authored
Jun 20, 2022
by
lizhiheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:新增一个取redis-key后缀的方法
parent
48635991
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
build.gradle
build.gradle
+1
-1
RedisBalanceKeyUtil.java
...iba/spring/boot/starter/dsp/util/RedisBalanceKeyUtil.java
+20
-0
No files found.
build.gradle
View file @
3b0342a7
...
@@ -38,7 +38,7 @@ allprojects {
...
@@ -38,7 +38,7 @@ allprojects {
}
}
group
=
"cn.com.duiba.boot"
group
=
"cn.com.duiba.boot"
version
=
"0.0.5
1
"
version
=
"0.0.5
2
"
}
}
subprojects
{
subprojects
{
...
...
spring-boot-starter-dsp-util/src/main/java/cn/com/duiba/spring/boot/starter/dsp/util/RedisBalanceKeyUtil.java
View file @
3b0342a7
...
@@ -57,4 +57,24 @@ public class RedisBalanceKeyUtil {
...
@@ -57,4 +57,24 @@ public class RedisBalanceKeyUtil {
}
}
return
null
;
return
null
;
}
}
/**
* 通过hash 然后取模获取指定的redis的suffix
*
* @param targetStr 目标字符串
* @return 返回指定节点对应的rediskey
*/
public
static
String
getRedisBalance8keySuffix
(
String
targetStr
)
{
String
HashStr
=
DigestUtils
.
md5Hex
(
targetStr
);
int
targetHashValue
=
HashAlgorithm
.
dekHash
(
HashStr
);
RedisBalance8KeyEnum
[]
values
=
RedisBalance8KeyEnum
.
values
();
int
mold
=
targetHashValue
%
(
values
.
length
);
for
(
RedisBalance8KeyEnum
keyEnum
:
values
)
{
if
(
Objects
.
equals
(
keyEnum
.
order
,
mold
))
{
String
key
=
keyEnum
.
hashTag
;
return
StringUtils
.
join
(
keyEnum
.
order
,
START
,
key
,
END
);
}
}
return
null
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment