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
f17bb6ac
Commit
f17bb6ac
authored
Jun 27, 2022
by
lizhiheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:新增个方法(根据字符串第一个字符的asc码取模)
parent
ae8cf865
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
build.gradle
build.gradle
+1
-1
RedisBalanceKeyUtil.java
...iba/spring/boot/starter/dsp/util/RedisBalanceKeyUtil.java
+21
-0
No files found.
build.gradle
View file @
f17bb6ac
...
...
@@ -38,7 +38,7 @@ allprojects {
}
group
=
"cn.com.duiba.boot"
version
=
"0.0.5
4
"
version
=
"0.0.5
6
"
}
subprojects
{
...
...
spring-boot-starter-dsp-util/src/main/java/cn/com/duiba/spring/boot/starter/dsp/util/RedisBalanceKeyUtil.java
View file @
f17bb6ac
...
...
@@ -134,4 +134,25 @@ public class RedisBalanceKeyUtil {
return
null
;
}
/**
* getRedisBalance8keySuffix的非hash版
* 从目标字符串中获取从左到右第一个数字或字母并且取模得到redisKey
*
* @param targetStr 目标字符串
* @return 返回指定节点对应的rediskey
*/
public
static
String
getRedisSuffixByFirstCharacterMold
(
String
targetStr
)
{
int
randomNum
=
targetStr
.
charAt
(
0
);
RedisBalance8KeyEnum
[]
values
=
RedisBalance8KeyEnum
.
values
();
int
mold
=
randomNum
%
(
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