|
@@ -41,7 +41,9 @@ public class IncNumber extends SerialRule {
|
|
RAtomicLong atomicLong = redissonClient.getAtomicLong(serialKey.toString());
|
|
RAtomicLong atomicLong = redissonClient.getAtomicLong(serialKey.toString());
|
|
if (!atomicLong.isExists()) {
|
|
if (!atomicLong.isExists()) {
|
|
atomicLong.set(startValue);
|
|
atomicLong.set(startValue);
|
|
- atomicLong.expire(timeToLive, TimeUnit.DAYS);
|
|
|
|
|
|
+ if (timeToLive > 0) {
|
|
|
|
+ atomicLong.expire(timeToLive, TimeUnit.DAYS);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return String.format("%" + digitsNum + "s", atomicLong.incrementAndGet()).replace(" ", "0");
|
|
return String.format("%" + digitsNum + "s", atomicLong.incrementAndGet()).replace(" ", "0");
|
|
}
|
|
}
|