Redis缓存使用

1、  引入依赖(可能已经引入了):spring-boot-starter-cache

2、  在application.yml配置文件中配置spring:redis:host/port/password,连接redis库

3、  在主启动程序中加入注解:@EnableChaching

4、在需要使用缓存的方法上加入注解:@Cacheable(cacheName=””.key=””)

5、返回页面的最外层对象需要序列化:实现接口serializable

6、使用generateSerialVersionUID插件在需要序列化的对象生成唯一ID(使用快捷键)

Redis缓存更新

方法一:在需要更新缓存的方法上加入注解:@CachePut(cacheName=””.key=””)

注意:有时候返回的数据不是json格式而是视图格式,这时候序列化就会失败,不能使用这个方法

方法二:在需要删除缓存的方法上加入注解:@CacheEvict(cacheName=””.key=””)

springboot-redis缓存的更多相关文章

  1. springboot redis 缓存对象

    只要加入spring-boot-starter-data-redis , springboot 会自动识别并使用redis作为缓存容器,使用方式如下 gradle加入依赖 compile(" ...

  2. SpringBoot Redis缓存 @Cacheable、@CacheEvict、@CachePut

    文章来源 https://blog.csdn.net/u010588262/article/details/81003493 1. pom.xml <dependency> <gro ...

  3. springboot Redis 缓存

    1,先整合 redis 和 mybatis 步骤一: springboot 整合 redis 步骤二: springboot 整合 mybatis 2,启动类添加 @EnableCaching 注解, ...

  4. springboot + redis缓存使用

    [参照资料] 1.spring boot 官网文档 2.https://www.cnblogs.com/gdpuzxs/p/7222309.html [项目结构] [pom.xml配置] <?x ...

  5. 从.Net到Java学习第七篇——SpringBoot Redis 缓存穿透

    从.Net到Java学习系列目录 场景描述:我们在项目中使用缓存通常都是先检查缓存中是否存在,如果存在直接返回缓存内容,如果不存在就直接查询数据库然后再缓存查询结果返回.这个时候如果我们查询的某一个数 ...

  6. 微服务-Springboot+Redis缓存管理接口代码实现

    废话少说,上代码,结合代码讲解: 一.创建maven工程:导入依赖: <packaging>war</packaging><!--修改jdk的版本--><pr ...

  7. springboot redis 缓存跨域丢失问题

    对于前后端分离的项目,在开发阶段经常会遇到跨域的问题. 1.首先,对于后台的处理方式,第一种是用 @CrossOrigin 注解,@crossorigin是后端SpringMVC框架(需4.2版本以上 ...

  8. spring-boot的spring-cache中的扩展redis缓存的ttl和key名

    原文地址:spring-boot的spring-cache中的扩展redis缓存的ttl和key名 前提 spring-cache大家都用过,其中使用redis-cache大家也用过,至于如何使用怎么 ...

  9. SpringBoot学习笔记(6) SpringBoot数据缓存Cache [Guava和Redis实现]

    https://blog.csdn.net/a67474506/article/details/52608855 Spring定义了org.springframework.cache.CacheMan ...

  10. java框架之SpringBoot(11)-缓存抽象及整合Redis

    Spring缓存抽象 介绍 Spring 从 3.1 版本开始定义了 org.springframework.cache.Cache 和 org.springframework.cache.Cache ...

随机推荐

  1. 解决方案看起来是受源代码管理,但无法找到它的绑定信息。保存解决方案的源代码管理设置的MSSCCPRJ.SCC文件或其他项可能己被删除。

    Visual Studio 2015 + SVN 开发环境,今天打开项目,就报了下面这个错误,先前是好好的! 解决方案看起来是受源代码管理,但无法找到它的绑定信息.保存解决方案的源代码管理设置的MSS ...

  2. MARS3.6 Programming

    An Assembly Language I.D.E. To Engage Students Of All Levels * A Tutorial *2007 CCSC: Central Plains ...

  3. latex 调整间隔

    转自:http://blog.sina.com.cn/s/blog_4a4927c70100phsb.html,感谢分享! 一.LATEX调整公式与正文间距离,调整空白大小:   调整空白命令: \s ...

  4. metasploit 连接database相关问题

    我们首先去这个目录下看database.yml文件内容: 下图是我们看到的的信息 接着打开metasploit,运行db_connect 指令链接数据库.格式为: db_connect 用户名:密码@ ...

  5. Excel使用SUMIF函数注意事项

    sumif函数的公式使用方法如下: =sumif(查询匹配的区域,条件,汇总求和的区域) 条件可以是“>10”或"=10"这种格式.其中“查询匹配区域”和“汇总求和区域”需要 ...

  6. 使用MapKit框架(持续更新)

    使用MapKit框架 地图显示 最简单显示地图的代码: // // RootViewController.m // CoreLocation // // Copyright (c) 2014年 Y.X ...

  7. GoAccess分析Nginx日志详解

    一.为了提高 GoAccess 分析准确度,建议配置 nginx.conf 的 log_format 项如下: log_format main '$remote_addr - $remote_user ...

  8. February 3 2017 Week 5 Friday

    Laughter is an instant vacation. 笑一笑,身心轻松宛如度了个短假. Always present a smile on your face, even there's ...

  9. 全新Chrome Devtool Performance使用指南

    运行时性能表现(runtime performance)指的是当你的页面在浏览器运行时的性能表现,而不是在下载页面的时候的表现.这篇指南将会告诉你怎么用Chrome DevToos Performan ...

  10. web服务器、app(应用)服务器、DB后端性能瓶颈和分析

    性能测试day07_性能瓶颈和分析 https://www.cnblogs.com/leixiaobai/p/9463748.html 其实如果之前都做的很到位的话,那么再加上APM工具(dynaTr ...