我是靠谱客的博主 俭朴背包,这篇文章主要介绍Redis——图片缓存,现在分享给大家,希望可以做个参考。

 

 

 

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@Autowired private RedisTemplate redisTemplate; @Override public List<TbContent> findByCategoryId(Long categoryId) { List<TbContent> contentList= (List<TbContent>) redisTemplate.boundHashOps("content").get(categoryId); if(contentList==null){ System.out.println("从数据库读取数据放入缓存"); //根据广告分类ID查询广告列表 TbContentExample contentExample=new TbContentExample(); Criteria criteria2 = contentExample.createCriteria(); criteria2.andCategoryIdEqualTo(categoryId); criteria2.andStatusEqualTo("1");//开启状态 contentExample.setOrderByClause("sort_order");//排序 contentList = contentMapper.selectByExample(contentExample);//获取广告列表 redisTemplate.boundHashOps("content").put(categoryId, contentList);//存入缓存 }else{ System.out.println("从缓存读取数据"); } return contentList; }

 

 

 

最后

以上就是俭朴背包最近收集整理的关于Redis——图片缓存的全部内容,更多相关Redis——图片缓存内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(63)

评论列表共有 0 条评论

立即
投稿
返回
顶部