多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
~~~ package com.nobb.util.cache; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; @Component public class RedisCache { //jdk 序列化 @Autowired private RedisTemplate redisTemplate; //string 序列化,推荐这个 @Autowired private StringRedisTemplate stringRedisTemplate; public Integer set(String key,String value){ stringRedisTemplate.opsForValue().set(key,value); return 1; } public String get(String key){ return stringRedisTemplate.opsForValue().get(key); } } ~~~