October 2017
Intermediate to advanced
396 pages
10h 2m
English
Spring's caching annotations allow you to turn off caching for some cases by using the condition attribute of @Cacheable and @CachePut annotations. These are given a SpEL expression to evaluate the conditional value. If the value of the conditional expression is true, the method is cached. If the value of the conditional expression is false, the method is not cached, but is executed every time without performing any caching operations no matter what values in the cache or what arguments are used. Let's see an example. The following method will be cached only if the passed argument has a value greater than or equal to 2000:
@Cacheable(cacheNames="accountCache", condition="#accountId >= 2000") public Account findAccount(Long ...
Read now
Unlock full access