Is it possible to give several conditions in @Cacheable?

Asked 2 years ago, Updated 2 years ago, 108 views

I want to use Cacheable Annotation to cache Spring.

I think there should be several conditions.

@Cacheable(value = "item", condition = "#filter.size == null")

It works fine with

@Cacheable(value = "item", condition = "#filter.size == null, #filter.color == null")

I don't think that's the moveYo

@Cacheable(value = "item", condition = "#filter.size == null", "#filter.color == null")

Enter your code here

I don't think this is it either. I'm curious.

spring java caching cacheable

2022-09-22 21:58

1 Answers

Since condition of @CacheableAnnotation is a SpEL (Spring Expression Language) expression, condition="#filter.size==null and #filter.color==null" or condition="#filter.size==null".

Note:


2022-09-22 21:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.