#
Junjie
2025-07-08 2342e5f8b991240272c27282ce2f1b3f9a3b3622
#
1个文件已修改
3 ■■■■■ 已修改文件
src/main/java/com/zy/common/utils/RedisUtil.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/RedisUtil.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.toolkit.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
@@ -149,6 +150,7 @@
    public boolean set(String key, Object value) {
        try {
            redisTemplate.opsForValue().set(key, value);
            redisTemplate.execute((RedisCallback<Void>) connection -> null);
            long start = System.currentTimeMillis();
            while (System.currentTimeMillis() - start < 10000) {//有效期10s
                Object o = redisTemplate.opsForValue().get(key);
@@ -182,6 +184,7 @@
            } else {
                set(key, value);
            }
            redisTemplate.execute((RedisCallback<Void>) connection -> null);
            return true;
        } catch (Exception e) {
            e.printStackTrace();