This commit is contained in:
2025-12-22 13:08:08 +08:00
parent 85e4513284
commit f0a6e03989
26 changed files with 2023 additions and 627 deletions

View File

@@ -47,6 +47,19 @@ public class RedisService {
redisTemplate.opsForValue().set(key, value, timeout, unit);
}
/**
* @description 如果key不存在则设置分布式锁
* @param key String 键
* @param value Object 值
* @param timeoutSeconds long 过期秒数
* @return Boolean 是否设置成功
* @author cascade
* @since 2025-12-22
*/
public Boolean setIfAbsent(String key, Object value, long timeoutSeconds) {
return redisTemplate.opsForValue().setIfAbsent(key, value, timeoutSeconds, TimeUnit.SECONDS);
}
/**
* @description 获取key对应的value
* @param key String 键