add 新增 RedisUtils.setObjectIfExists 如果存在则设置方法
parent
6bcf7f528c
commit
1f6d649131
|
|
@ -141,6 +141,18 @@ public class RedisUtils {
|
||||||
return bucket.setIfAbsent(value, duration);
|
return bucket.setIfAbsent(value, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果存在则设置 并返回 true 如果存在则返回 false
|
||||||
|
*
|
||||||
|
* @param key 缓存的键值
|
||||||
|
* @param value 缓存的值
|
||||||
|
* @return set成功或失败
|
||||||
|
*/
|
||||||
|
public static <T> boolean setObjectIfExists(final String key, final T value, final Duration duration) {
|
||||||
|
RBucket<T> bucket = CLIENT.getBucket(key);
|
||||||
|
return bucket.setIfExists(value, duration);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册对象监听器
|
* 注册对象监听器
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue