@CacheDefaults

@CacheDefaults allows you to define at the cache level, the cache name, the resolver factory, and the key generator to use. It prevents having to do it on all the methods if they all share the same setup:

@ApplicationScoped@CacheDefaults(    cacheName = "packt.quotes",    cacheResolverFactory = AppCacheResolverFactory.class,    cacheKeyGenerator = QuoteCacheGenerator.class)public class CachedQuoteService {    @Inject    private QuoteService service;    @CachePut    public Quote create(final Quote newQuote) {        return service.create(newQuote);    }    @CacheRemove    public Quote delete(final Quote quote) {        return service.delete(quote);    }}

This class, which delegates the logic to a dedicated service, has two methods using JCache CDI integration. Both are using ...

Get Java EE 8 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.