当前位置:
首页 >
【spring-boot】启用数据缓存功能
发布时间:2024/9/19
53
豆豆
生活随笔
收集整理的这篇文章主要介绍了
【spring-boot】启用数据缓存功能
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
前言
- spring-boot : 2.1.1.RELEASE
步骤简述
2.1 查询数据功能上添加注解:@Cacheable
2.2 添加、修改数据功能上添加注解:@CachePut
2.3 删除数据功能上添加注解:@CacheEvict
示例
略。
扩展
如果未定义 CacheManager Bean,或者未定义名为 cacheResolver 的 CacheResolver Bean时,Spring Boot 按照下面的顺序尝试启用缓存:
其中 9. Simple 是兜底的方式。也就是说,一旦添加注解 @EnableCaching ,缓存功能100%的启用。
官方关于 9. Simple 的说明:
If none of the other providers can be found, a simple implementation using a ConcurrentHashMap as the cache store is configured. This is the default if no caching library is present in your application.
如果在已添加注解 @EnableCaching 的情况下,还要禁用缓存,那么,使用配置:
spring.cache.type=none参考
https://docs.spring.io/spring-boot/docs/2.1.1.RELEASE/reference/htmlsingle/#boot-features-caching-provider
总结
以上是生活随笔为你收集整理的【spring-boot】启用数据缓存功能的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 【SpEL】随机数
- 下一篇: ECMAScript标准资料