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

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

 

 

 

 

資料簡(jiǎn)介:

 

Redis工具類(lèi)
public final class RedisServiceImpl implements RedisService {
/**
* 過(guò)期時(shí)長(zhǎng)
*/
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大后端
專(zhuān)注分享Java技術(shù)干貨,包括Java多線程、IO、JVM、Spring Boot、Spring Cloud、…
公眾號(hào)
 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);
}
}