admin
2021-05-08 db5abf468e5f2d00e51f8bd4a267484879a73451
lib-common/src/main/java/com/ks/lib/common/util/RedisUtil.java
@@ -42,7 +42,7 @@
     */
    public long getExpire(String key) {
        return redisTemplate.getExpire(key, TimeUnit.SECONDS);
        return redisTemplate.getExpire(key);
    }
    /**
@@ -346,7 +346,7 @@
     * @return
     */
    public double hincr(String key, String item, double by) {
    public double hincr(String key, String item, long by) {
        return redisTemplate.opsForHash().increment(key, item, by);
@@ -361,7 +361,7 @@
     * @return
     */
    public double hdecr(String key, String item, double by) {
    public double hdecr(String key, String item, long by) {
        return redisTemplate.opsForHash().increment(key, item, -by);
@@ -409,12 +409,12 @@
     * @param values 值 可以是多个
     * @return 成功个数
     */
    public long sSet(String key, Object... values) {
    public boolean sSet(String key, Object... values) {
        try {
            return redisTemplate.opsForSet().add(key, values);
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
            return false;
        }
    }
@@ -426,15 +426,15 @@
     * @param values 值 可以是多个
     * @return 成功个数
     */
    public long sSetAndTime(String key, long time, Object... values) {
    public boolean sSetAndTime(String key, long time, Object... values) {
        try {
            Long count = redisTemplate.opsForSet().add(key, values);
          boolean count = redisTemplate.opsForSet().add(key, values);
            if (time > 0)
                expire(key, time);
            return count;
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
            return false;
        }
    }
@@ -461,13 +461,12 @@
     * @return 移除的个数
     */
    public long setRemove(String key, Object... values) {
    public boolean setRemove(String key, Object... values) {
        try {
            Long count = redisTemplate.opsForSet().remove(key, values);
            return count;
          return redisTemplate.opsForSet().remove(key, values);
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
            return false;
        }
    }
@@ -564,45 +563,6 @@
        }
    }
    /**
     * 将list放入缓存
     *
     * @param key   键
     * @param value 值
     * @return
     */
    public boolean lSet(String key, List<Object> value) {
        try {
            redisTemplate.opsForList().rightPushAll(key, value);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    /**
     * 将list放入缓存
     *
     * @param key   键
     * @param value 值
     * @param time  时间(秒)
     * @return
     */
    public boolean lSet(String key, List<Object> value, long time) {
        try {
            redisTemplate.opsForList().rightPushAll(key, value);
            if (time > 0) {
                expire(key, time);
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    /**
     * 根据索引修改list中的某条数据