PC
2024-03-30 e46f64d9f9f26531af2104afd2c46ec6b05c430c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.qianwen.core.social.cache;
 
import java.util.concurrent.TimeUnit;
import me.zhyd.oauth.cache.AuthCacheConfig;
import me.zhyd.oauth.cache.AuthStateCache;
import com.qianwen.core.tool.utils.Func;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
 
/* loaded from: blade-starter-social-9.3.2.0-SNAPSHOT.jar:org/springblade/core/social/cache/AuthStateRedisCache.class */
public class AuthStateRedisCache implements AuthStateCache {
    private final RedisTemplate<String, Object> redisTemplate;
    private final ValueOperations<String, Object> valueOperations;
 
    public AuthStateRedisCache(final RedisTemplate<String, Object> redisTemplate, final ValueOperations<String, Object> valueOperations) {
        this.redisTemplate = redisTemplate;
        this.valueOperations = valueOperations;
    }
 
    public void cache(String key, String value) {
        this.valueOperations.set(key, value, AuthCacheConfig.timeout, TimeUnit.MILLISECONDS);
    }
 
    public void cache(String key, String value, long timeout) {
        this.valueOperations.set(key, value, timeout, TimeUnit.MILLISECONDS);
    }
 
    public String get(String key) {
        return Func.toStr(this.valueOperations.get(key), (String) null);
    }
 
    public boolean containsKey(String key) {
        return this.redisTemplate.hasKey(key).booleanValue();
    }
}