| | |
| | | |
| | | import cn.dev33.satoken.dao.SaTokenDao; |
| | | import cn.dev33.satoken.util.SaFoxUtil; |
| | | import cn.hutool.core.lang.Console; |
| | | import com.github.benmanes.caffeine.cache.Cache; |
| | | import com.github.benmanes.caffeine.cache.Caffeine; |
| | | import org.dromara.common.redis.utils.RedisUtils; |
| | |
| | | if (timeout == NEVER_EXPIRE) { |
| | | RedisUtils.setCacheObject(key, value); |
| | | } else { |
| | | RedisUtils.setCacheObject(key, value, Duration.ofSeconds(timeout)); |
| | | if (RedisUtils.hasKey(key)) { |
| | | RedisUtils.setCacheObject(key, value, true); |
| | | } else { |
| | | RedisUtils.setCacheObject(key, value, Duration.ofSeconds(timeout)); |
| | | } |
| | | } |
| | | CAFFEINE.put(key, value); |
| | | CAFFEINE.invalidate(key); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void update(String key, String value) { |
| | | if (RedisUtils.hasKey(key)) { |
| | | RedisUtils.setCacheObject(key, value, true); |
| | | CAFFEINE.put(key, value); |
| | | CAFFEINE.invalidate(key); |
| | | } |
| | | } |
| | | |
| | |
| | | if (timeout == NEVER_EXPIRE) { |
| | | RedisUtils.setCacheObject(key, object); |
| | | } else { |
| | | RedisUtils.setCacheObject(key, object, Duration.ofSeconds(timeout)); |
| | | if (RedisUtils.hasKey(key)) { |
| | | RedisUtils.setCacheObject(key, object, true); |
| | | } else { |
| | | RedisUtils.setCacheObject(key, object, Duration.ofSeconds(timeout)); |
| | | } |
| | | } |
| | | CAFFEINE.put(key, object); |
| | | CAFFEINE.invalidate(key); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void updateObject(String key, Object object) { |
| | | if (RedisUtils.hasKey(key)) { |
| | | RedisUtils.setCacheObject(key, object, true); |
| | | CAFFEINE.put(key, object); |
| | | CAFFEINE.invalidate(key); |
| | | } |
| | | } |
| | | |