springboot redis 静态工具类
作者:互联网
@Slf4j
@Component
public class RedisUtils {
private static RedisTemplate<Object, Object> redisTemplate;
@Autowired
public void setRedisService(RedisTemplate redisTemplate) {
RedisUtils.redisTemplate = redisTemplate;
}
public static void setValue(Object key, Object value) {
try {
ValueOperations<Object, Object> vp = redisTemplate.opsForValue();
vp.set(key, value);
} catch (Exception e) {
log.error("", e);
}
}
}
标签:springboot,静态,Object,redis,value,vp,static,public,redisTemplate 来源: https://www.cnblogs.com/keguankele/p/16300762.html