springboot-cache + reds整合
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                springboot-cache + reds整合
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                版權聲明:本文為博主原創文章,歡迎轉載,轉載請注明作者、原文超鏈接
maven:
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-cache</artifactId> </dependency>啟動類
@SpringBootApplication @EnableCaching public class CollectionApplication {public static void main(String[] args) {SpringApplication.run(CollectionApplication.class, args);} }service:
@Service @CacheConfig(cacheNames = "myCache") public class CacheServiceImpl implements CacheService {//操作字符串@Autowiredprivate StringRedisTemplate stringRedisTemplate;//操作對象@AutowiredRedisTemplate redisTemplate;@Override@Cacheable(key = "targetClass + methodName +#p0")public User queryUser(String username) {User user = new User();user.setAddress("北京");user.setAge(26);user.setBirthday(new Date());user.setUserName(username);//stringRedisTemplate.opsForValue().set("username","ethan");return user;} }再次訪問就會調用redis中的值。
 redis-cli 里查看key
詳細學習參考 https://www.cnblogs.com/yueshutong/p/9381540.html
總結
以上是生活随笔為你收集整理的springboot-cache + reds整合的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: Android基础知识复习之打开照相机拍
- 下一篇: SPI总线的原理与Verilog实现
