Python知識分享網(wǎng) - 專業(yè)的Python學(xué)習(xí)網(wǎng)站 學(xué)Python,上Python222
JWT 實現(xiàn)登錄認(rèn)證 + Token 自動續(xù)期方案,這才是正確的使用姿勢! PDF 下載
匿名網(wǎng)友發(fā)布于:2024-01-14 10:09:05
(侵權(quán)舉報)
(假如點擊沒反應(yīng),多刷新兩次就OK!)

JWT 實現(xiàn)登錄認(rèn)證 + Token 自動續(xù)期方案,這才是正確的使用姿勢! PDF 下載  圖1

 

 

 

 

資料簡介:

 

Redis工具類
public final class RedisServiceImpl implements RedisService {
/**
* 過期時長
*/
private final Long DURATION = 1 * 24 * 60 * 60 * 1000L;
@Resource
private RedisTemplate redisTemplate;
private ValueOperations<String, String> valueOperations;
@PostConstruct
public void init() {
RedisSerializer redisSerializer = new StringRedisSerializer();
redisTemplate.setKeySerializer(redisSerializer);
redisTemplate.setValueSerializer(redisSerializer);
redisTemplate.setHashKeySerializer(redisSerializer);
redisTemplate.setHashValueSerializer(redisSerializer);
valueOperations = redisTemplate.opsForValue();
}
@Override
public void set(String key, String value) {
valueOperations.set(key, value, DURATION, TimeUnit.MILLISECONDS);
log.info("key={}, value is: {} into redis cache", key, value);
}
@Override
public String get(String key) {
String redisValue = valueOperations.get(key);
log.info("get from redis, value is: {}", redisValue);
return redisValue;
}
@Override
Java大后端
專注分享Java技術(shù)干貨,包括Java多線程、IO、JVM、Spring Boot、Spring Cloud、…
公眾號
 public boolean delete(String key) {
boolean result = redisTemplate.delete(key);
log.info("delete from redis, key is: {}", key);
return result;
}
@Override
public Long getExpireTime(String key) {
return valueOperations.getOperations().getExpire(key);
}
}