疯狂的狮子Li
2023-07-12 1dc718291b818a41cf52a0b27eed70d7bb8838dd
ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java
@@ -2,8 +2,8 @@
import lombok.AllArgsConstructor;
import me.zhyd.oauth.cache.AuthStateCache;
import org.dromara.common.core.constant.GlobalConstants;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.social.config.properties.SocialProperties;
import java.time.Duration;
@@ -13,8 +13,6 @@
@AllArgsConstructor
public class AuthRedisStateCache implements AuthStateCache {
    private final SocialProperties socialProperties;
    /**
     * 存入缓存
     *
@@ -23,7 +21,8 @@
     */
    @Override
    public void cache(String key, String value) {
        RedisUtils.setCacheObject(key, value, Duration.ofMillis(socialProperties.getTimeout()));
        // 授权超时时间 默认三分钟
        RedisUtils.setCacheObject(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key, value, Duration.ofMinutes(3));
    }
    /**
@@ -35,7 +34,7 @@
     */
    @Override
    public void cache(String key, String value, long timeout) {
        RedisUtils.setCacheObject(key, value, Duration.ofMillis(timeout));
        RedisUtils.setCacheObject(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key, value, Duration.ofMillis(timeout));
    }
    /**
@@ -46,7 +45,7 @@
     */
    @Override
    public String get(String key) {
        return RedisUtils.getCacheObject(key);
        return RedisUtils.getCacheObject(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key);
    }
    /**
@@ -57,6 +56,6 @@
     */
    @Override
    public boolean containsKey(String key) {
        return RedisUtils.hasKey(key);
        return RedisUtils.hasKey(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key);
    }
}