chatRoom
This commit is contained in:
@@ -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 键
|
||||
|
||||
Reference in New Issue
Block a user