| | |
| | | |
| | | 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; |
| | | |
| | |
| | | @AllArgsConstructor |
| | | public class AuthRedisStateCache implements AuthStateCache { |
| | | |
| | | private final SocialProperties socialProperties; |
| | | |
| | | /** |
| | | * 存入缓存 |
| | | * |
| | |
| | | */ |
| | | @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)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @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)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public String get(String key) { |
| | | return RedisUtils.getCacheObject(key); |
| | | return RedisUtils.getCacheObject(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public boolean containsKey(String key) { |
| | | return RedisUtils.hasKey(key); |
| | | return RedisUtils.hasKey(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key); |
| | | } |
| | | } |