2023-11-14 18:19:47 +08:00
|
|
|
package com.example.chat.dao.redis;
|
|
|
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.data.redis.core.ValueOperations;
|
|
|
|
import org.springframework.stereotype.Repository;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
@Repository
|
2023-11-21 13:07:56 +08:00
|
|
|
public class TokenRedis implements RedisUtil {
|
2023-11-14 18:19:47 +08:00
|
|
|
|
|
|
|
@Resource
|
|
|
|
StringRedisTemplate stringRedisTemplate;
|
2023-11-21 13:07:56 +08:00
|
|
|
|
2023-11-14 18:19:47 +08:00
|
|
|
@Override
|
|
|
|
public void addRedis(String key, String value) {
|
2023-11-21 13:07:56 +08:00
|
|
|
ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue();
|
|
|
|
valueOperations.set(key, value, 60, TimeUnit.MINUTES);
|
2023-11-14 18:19:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void delRedis(String key) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getRedis(String key) {
|
|
|
|
return stringRedisTemplate.opsForValue().get(key);
|
|
|
|
}
|
|
|
|
}
|