diff --git a/ruoyi-common/ruoyi-common-satoken/src/main/java/org/dromara/common/satoken/core/dao/PlusSaTokenDao.java b/ruoyi-common/ruoyi-common-satoken/src/main/java/org/dromara/common/satoken/core/dao/PlusSaTokenDao.java index 8d2aac96..d8859622 100644 --- a/ruoyi-common/ruoyi-common-satoken/src/main/java/org/dromara/common/satoken/core/dao/PlusSaTokenDao.java +++ b/ruoyi-common/ruoyi-common-satoken/src/main/java/org/dromara/common/satoken/core/dao/PlusSaTokenDao.java @@ -45,12 +45,9 @@ public class PlusSaTokenDao implements SaTokenDao { */ @Override public void update(String key, String value) { - long expire = getTimeout(key); - // -2 = 无此键 - if (expire == NOT_VALUE_EXPIRE) { - return; + if (RedisUtils.hasKey(key)) { + RedisUtils.setCacheObject(key, value, true); } - this.set(key, value, expire); } /** @@ -75,17 +72,6 @@ public class PlusSaTokenDao implements SaTokenDao { */ @Override public void updateTimeout(String key, long timeout) { - // 判断是否想要设置为永久 - if (timeout == NEVER_EXPIRE) { - long expire = getTimeout(key); - if (expire == NEVER_EXPIRE) { - // 如果其已经被设置为永久,则不作任何处理 - } else { - // 如果尚未被设置为永久,那么再次set一次 - this.set(key, this.get(key), timeout); - } - return; - } RedisUtils.expire(key, Duration.ofSeconds(timeout)); } @@ -119,12 +105,9 @@ public class PlusSaTokenDao implements SaTokenDao { */ @Override public void updateObject(String key, Object object) { - long expire = getObjectTimeout(key); - // -2 = 无此键 - if (expire == NOT_VALUE_EXPIRE) { - return; + if (RedisUtils.hasKey(key)) { + RedisUtils.setCacheObject(key, object, true); } - this.setObject(key, object, expire); } /** @@ -149,17 +132,6 @@ public class PlusSaTokenDao implements SaTokenDao { */ @Override public void updateObjectTimeout(String key, long timeout) { - // 判断是否想要设置为永久 - if (timeout == NEVER_EXPIRE) { - long expire = getObjectTimeout(key); - if (expire == NEVER_EXPIRE) { - // 如果其已经被设置为永久,则不作任何处理 - } else { - // 如果尚未被设置为永久,那么再次set一次 - this.setObject(key, this.getObject(key), timeout); - } - return; - } RedisUtils.expire(key, Duration.ofSeconds(timeout)); }