October 2017
Intermediate to advanced
396 pages
10h 2m
English
Spring's cache abstraction allows you to annotate @CacheConfig at the class level to avoid repeated mentioning in each method. In some cases, applying customizations of the caches to all methods can be quite tedious. Here, you can use the @CacheConfig annotation to all operations of the class. For example:
@CacheConfig("accountCache ")
public class AccountServiceImpl implements AccountService {
@Cacheable
public Account findAccount(Long accountId) {
return (Account) accountRepository.findOne(accountId);
}
}
You can see in the preceding code snippet that the @CacheConfig annotation is used at the class level, and it allows you to share the accountCache cache with all the cacheable methods.
Read now
Unlock full access