@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 ...