springboot缓存注解——@Cacheable和@CacheConfig
@Caching :制定多个缓存规则
@Cacheable 和 @CachePut 同时标注时 ,@CachePut导致还是会走方法跟数据库交互
//根据lastName查,并将结果缓存,并且可以用于下次通过id或者email查询
(因为有Cacheput注解,所有根据lastName查的方法还是会执行) @Caching(
cacheable = {@Cacheable(/*value = "emp",*/key = "#lastName")},
put = {@CachePut(/*value = "emp",*/key = "#result.id"),@CachePut(/*value = "emp",*/key = "#result.email")}
)
public Employee getEmpByLastName(String lastName){
System.out.println("根据...."+lastName+"查询员工");
return employeeMapper.getEmpByLastName(lastName);
}
另外:
@CacheConfig :抽取缓存公共配置,可以标注在类上
如:
@CacheConfig(cacheNames = "emp")
@Service
public class EmployeeService
springboot缓存注解——@Cacheable和@CacheConfig的更多相关文章
- springboot缓存注解——@Cacheable
@Cacheable: 1,方法运行之前,先查询Cache(缓存组件),按照cacheName指定的名字获取(CacheManager获取相应缓存) 第一次获取缓存如果没有Cache组件会自会自动创建 ...
- SpringBoot:缓存注解@Cacheable详解
1.查看@Cacheable @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @ ...
- Spring之缓存注解@Cacheable
https://www.cnblogs.com/fashflying/p/6908028.html https://blog.csdn.net/syani/article/details/522399 ...
- 详解Spring缓存注解@Cacheable,@CachePut , @CacheEvict使用
https://blog.csdn.net/u012240455/article/details/80844361 注释介绍 @Cacheable @Cacheable 的作用 主要针对方法配置,能够 ...
- spring-boot -缓存注解
缓存:商品信息放到缓存中间件中, 验证码几秒钟有效也是放在缓存中间件. 缓存规范 交互流程: 如果需要使用jRS107需要导入包: java.cache.cache-api JSR107提供的是接口, ...
- Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用(转)
原文地址:https://www.cnblogs.com/fashflying/p/6908028.html 从3.1开始,Spring引入了对Cache的支持.其使用方法和原理都类似于Spring对 ...
- Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用
从3.1开始,Spring引入了对Cache的支持.其使用方法和原理都类似于Spring对事务管理的支持.Spring Cache是作用在方法上的,其核心思想是这样的:当我们在调用一个缓存方法时会把该 ...
- 缓存注解@Cacheable、@CacheEvict、@CachePut使用及注解失效时间
从3.1开始,Spring引入了对Cache的支持.其使用方法和原理都类似于Spring对事务管理的支持.Spring Cache是作用在方法上的,其核心思想是这样的:当我们在调用一个缓存方法时会把该 ...
- SpringBoot 缓存注解 与EhCache的使用
在SpringBoot工程中配置EhCache缓存 1.在src/main/resources下新建ehcache.xml文件 eternal=true //缓存永久有效,false相反 maxEle ...
随机推荐
- locust压测websocket协议
Locust是以HTTP为主要目标构建的. 但是,通过编写触发器request_success和 request_failure事件的自定义客户端,可以轻松扩展到任何基于请求/响应的系统的负载测试 . ...
- Vue.js数据响应基础原理
许多前端JavaScript框架(例如Angular,React和Vue)都有自己的数据相应引擎.通过了解相应性及其工作原理,您可以提高开发技能并更有效地使用JavaScript框架.在视频和下面的文 ...
- spring-data-radis错误
org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested ...
- linux----------fedora 27 如何启用输入法
1.安装完成以后是自带了输入法的,但是需要启用. 一定要放到第一个位置,然后注销或者重启.
- angular2--Tour of Heroes学习和分析--路由
引入路由模块时的一个报错 No base href set. Please provide a value for the APP_BASE_HREF token or add a base elem ...
- 架构设计---soa与msa的概念(转)
https://blog.csdn.net/qq_15001229/article/details/79535037
- 【论文速读】Chuhui Xue_ECCV2018_Accurate Scene Text Detection through Border Semantics Awareness and Bootstrapping
Chuhui Xue_ECCV2018_Accurate Scene Text Detection through Border Semantics Awareness and Bootstrappi ...
- 【转】完美解决Python与anaconda之间的冲突问题
本文转自:https://blog.csdn.net/sinat_41898105/article/details/80660332 anaconda指的是一个开源的Python发行版本,其包含了co ...
- MySQL 压缩文件安装遇到的问题及解决方案
第一步:从官网下载压缩文件(链接). 第二步:解压该文件,放置到想放到的位置.我的目录是在 C:\mysql\mysql-8.0.12-winx64 下. 第三步:在C:\mysql\mysql-8. ...
- GoldenGate for bigdata 12.3.2.1版本新特性
在Oracle Tenical Network(OTN)上已经可以下载到最新的ogg4bd版本,地址如下:http://www.oracle.com/technetwork/middleware/go ...