疯狂的狮子Li
2023-07-02 06588f3ad4cdc711cd349fbca25e43960bcb8562
ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java
@@ -1,32 +1,19 @@
package org.dromara.common.social.utils;
import jakarta.annotation.PostConstruct;
import lombok.AllArgsConstructor;
import me.zhyd.oauth.cache.AuthStateCache;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.social.config.properties.SocialProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import java.time.Duration;
/**
 * 授权状态缓存
 */
@AllArgsConstructor
public class AuthRedisStateCache implements AuthStateCache {
    private final SocialProperties socialProperties;
    private final RedisTemplate<String, String> redisTemplate;
    private ValueOperations<String, String> valueOperations;
    @PostConstruct
    public void init() {
        valueOperations = redisTemplate.opsForValue();
    }
    public AuthRedisStateCache() {
        this.socialProperties = new SocialProperties();
        redisTemplate = new RedisTemplate<>();
    }
    /**
     * 存入缓存
@@ -36,7 +23,6 @@
     */
    @Override
    public void cache(String key, String value) {
        // TODO: 自定义存入缓存
        RedisUtils.setCacheObject(key, value, Duration.ofMillis(socialProperties.getTimeout()));
    }
@@ -49,7 +35,6 @@
     */
    @Override
    public void cache(String key, String value, long timeout) {
        // TODO: 自定义存入缓存
        RedisUtils.setCacheObject(key, value, Duration.ofMillis(timeout));
    }
@@ -61,7 +46,6 @@
     */
    @Override
    public String get(String key) {
        // TODO: 自定义获取缓存内容
        return RedisUtils.getCacheObject(key);
    }
@@ -73,7 +57,6 @@
     */
    @Override
    public boolean containsKey(String key) {
        // TODO: 自定义判断key是否存在
        return RedisUtils.hasKey(key);
    }
}