update 优化发号器工具类删除前缀

This commit is contained in:
AprilWind 2025-07-03 17:00:13 +08:00
parent 7cd9c4b4e0
commit 4ef13cb9b4

View File

@ -67,7 +67,7 @@ public class SequenceUtils {
initValue = (initValue == null || initValue <= 0) ? DEFAULT_INIT_VALUE : initValue;
stepValue = (stepValue == null || stepValue <= 0) ? DEFAULT_STEP_VALUE : stepValue;
RIdGenerator idGenerator = REDISSON_CLIENT.getIdGenerator(key);
RIdGenerator idGenerator = REDISSON_CLIENT.getIdGenerator(DEFAULT_PREFIX + key);
try {
// 初始化成功后设置过期时间避免多线程反复设置
if (idGenerator.tryInit(initValue, stepValue)) {
@ -84,7 +84,7 @@ public class SequenceUtils {
* 构建标准的业务 key加上默认前缀
*/
private static String generateKey(String prefix, String suffix) {
return StringUtils.format("{}{}{}", DEFAULT_PREFIX, StringUtils.blankToDefault(prefix, ""), suffix);
return StringUtils.format("{}{}", StringUtils.blankToDefault(prefix, ""), suffix);
}
/**