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 ...
随机推荐
- supervise守护进程
通过二进制supervise文件可以直接对进程进行守护 ./supervise -f 要守护的程序 -p 守护信息存储位置 例如: ./supervise -f http_server -p s ...
- Mybatis下的sql注入
以前只知道mybatis框架下,order by后面接的是列名是不能用#{},这样不起效果,只能用${},这样的话就可能产生sql注入.后来发现其实还有另外两种情况也是类似的: 1.order by ...
- 下载caffe慢
国内在github上下载软件慢,应在gitee下载git clone https://gitee.com/cuibixuan/caffe.git
- 记一次ORACLE无法启动登陆事故
打开XSHELL 登陆ORACLE用户 1.sqlplus scott/scott 提示登陆失败 2.sqplus / as sysdba 启动数据库提示 3.查找日志 操作日志:$ORACLE_HO ...
- jpa报错:Table 'dev-test.hibernate_sequence' doesn't exist
Hibernate 能够出色地自动生成主键.Hibernate/EBJ 3 注释也可以为主键的自动生成提供丰富的支持,允许实现各种策略.其生成规则由@GeneratedValue设定的.这里的@id和 ...
- OxyPlot Controller OxyPlot控制器
Default input bindings The default input bindings in the PlotController are: Action Gesture Pan* Rig ...
- arcgis for js 之 获取两点之间的距离
换了新公司,接触新行业,半路出家,看着别人的代码,看着api慢慢理解. 需求如下:已知两点坐标求距离. 思路,没有,站在同事的肩膀上踩路子,给的这个链接 https://developers.arcg ...
- mysql恢复备份数据时,部分表数据丢失的问题
原因:是由于默认的通信缓冲区的最大长度为50M(max_allowed_packed). 处理办法: //查看当前max_allowed_packet的大小 show global variables ...
- textfield reload issue and other things reload problem.===================================
https://github.com/flutter/flutter/issues/18828 https://blog.csdn.net/u011272795/article/details/830 ...
- Linux nmcli 网络管理
Linux nmcli 网络管理 RHEL 和 CentOS 系统默认使用 NetworkManager 来提供网络服务,这是一种动态管理网络配置的守护进程,能够让网络设备保持连接状态.可以使用 nm ...