Commit ae8cf865 authored by lizhiheng's avatar lizhiheng

feat:版本号升级

parent 70674685
......@@ -38,7 +38,7 @@ allprojects {
}
group = "cn.com.duiba.boot"
version = "0.0.53"
version = "0.0.54"
}
subprojects {
......
......@@ -60,6 +60,26 @@ public class RedisBalanceKeyUtil {
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;
}
/**
* getRedisBalance8key的非hash版
* 从目标字符串中获取从左到右第一个数字并且取模得到redisKey
......@@ -88,16 +108,23 @@ public class RedisBalanceKeyUtil {
}
/**
* 通过hash 然后取模获取指定的redis的suffix
* getRedisBalance8keySuffix的非hash版
* 从目标字符串中获取从左到右第一个数字并且取模得到redisKey
*
* @param targetStr 目标字符串
* @return 返回指定节点对应的rediskey
*/
public static String getRedisBalance8keySuffix(String targetStr) {
String HashStr = DigestUtils.md5Hex(targetStr);
int targetHashValue = HashAlgorithm.dekHash(HashStr);
public static String getRedisSuffixByFirstNumMold(String targetStr) {
int randomNum = 0;
for (int i = 0; i < targetStr.length(); i++) {
char c = targetStr.charAt(i);
if (c >= 48 && c <= 57) {
randomNum = c;
break;
}
}
RedisBalance8KeyEnum[] values = RedisBalance8KeyEnum.values();
int mold = targetHashValue % (values.length);
int mold = randomNum % (values.length);
for (RedisBalance8KeyEnum keyEnum : values) {
if (Objects.equals(keyEnum.order, mold)) {
String key = keyEnum.hashTag;
......@@ -106,4 +133,5 @@ public class RedisBalanceKeyUtil {
}
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment