src/main/java/com/hx/redis/RedisUtil.java
@@ -363,4 +363,19 @@ } } /** * @param key 键 * @param value 值 * @param timeOut 时间 * @param unit 时间单位 */ public Boolean setIfAbsent(String key, Object value, long timeOut, TimeUnit unit) { try { return redisTemplate.opsForValue().setIfAbsent(key, value, timeOut, unit); } catch (Exception e) { e.printStackTrace(); return null; } } }