/**
* 获取指定 key 的自增序列值
* @param key redis key
* @return 自增序列值
*/
public Long getIncreaseSeq(String key) {
Long currentValue = valueOperations.increment(key);
if (currentValue == null) {
synchronized (this) {
valueOperations.set(key, "1");
currentValue = 1L;
}
}
return currentValue;
}
Java 实现 Redis 自增序列获取
最新推荐文章于 2024-04-12 09:54:20 发布