彭雪彬
2025-07-14 eb77373d92f01e51b98bda8fae66315ed9a4394d
oying-common/src/main/java/com/oying/utils/RedisUtils.java
@@ -392,6 +392,27 @@
        }
    }
    /**
     * 分布式ID生成器
     *
     * @param key   键
     * @param value 值
     * @param time  时间(秒) time要大于0 如果time小于等于0 将设置无限期,注意:这里将会替换原有的时间
     * @return true成功 false 失败
     */
    public boolean setIfAbsent(String key, Object value, long time) {
        try {
            if (time > 0) {
                Boolean result = redisTemplate.opsForValue().setIfAbsent(key, value, time, TimeUnit.SECONDS);
                return result;
            } else {
                return false;
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return false;
        }
    }
    // ================================Map=================================
    /**