From 1dc718291b818a41cf52a0b27eed70d7bb8838dd Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期三, 12 七月 2023 14:18:41 +0800 Subject: [PATCH] update 优化 三方认证使用 Redis 缓存授权状态 --- ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java index ae58348..0b6ec20 100644 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java +++ b/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); } } -- Gitblit v1.9.3