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();
|
}
|
}
|