mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 08:13:44 +08:00 
			
		
		
		
	add 新增 RedisUtils.setObjectIfAbsent 不存在则设置 方法
This commit is contained in:
		@@ -129,6 +129,18 @@ public class RedisUtils {
 | 
			
		||||
        batch.execute();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 如果不存在则设置 并返回 true 如果存在则返回 false
 | 
			
		||||
     *
 | 
			
		||||
     * @param key   缓存的键值
 | 
			
		||||
     * @param value 缓存的值
 | 
			
		||||
     * @return set成功或失败
 | 
			
		||||
     */
 | 
			
		||||
    public static <T> boolean setObjectIfAbsent(final String key, final T value, final Duration duration) {
 | 
			
		||||
        RBucket<T> bucket = CLIENT.getBucket(key);
 | 
			
		||||
        return bucket.setIfAbsent(value, duration);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 注册对象监听器
 | 
			
		||||
     * <p>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user