@Cacheable的属性unless
时间: 2023-10-02 10:04:36 浏览: 118
详解Spring缓存注解@Cacheable,@CachePut , @CacheEvict使用
@Cacheable的属性unless是用来指定一个SpEL表达式,表示在方法执行后检查返回结果是否满足条件,如果满足条件则不会将结果缓存起来。在上述引用和引用的例子中,属性unless的值为"#result == null",表示如果方法返回的结果为空(null),则不会将结果缓存起来。换句话说,只有当方法返回的结果不为空时,才会将结果缓存。这样可以避免将无效的数据缓存起来,节省了缓存空间。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [详解Spring缓存注解@Cacheable,@CachePut , @CacheEvict使用](https://download.csdn.net/download/weixin_38611877/12781025)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Spring Cache的@Cacheable注解的condition属性与unless属性细节问题;Redis每日一坑](https://blog.csdn.net/qq_45839663/article/details/127208978)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [Spring Cache的@Cacheable注解的condition属性与unless属性细节问题](https://blog.csdn.net/m0_56265851/article/details/126389539)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文