Hands-On High Performance with Spring 5
by Chintan Mehta, Subhash Shah, Pritesh Shah, Prashant Goswami, Dinesh Radadiya
Caching
In order to improve the performance of an application, caching heavy operations is inevitable. Spring 3.1 added a great abstraction layer called caching that helped to abandon all custom-implemented aspects, decorators, and code injected into the business logic related to caching.
Spring applies caching to the methods of Spring beans using AOP concepts; we learned about it in the AOP concepts section of this chapter. Spring creates proxies of the Spring beans where the methods are annotated to be cached.
In order to leverage the benefits of Spring's caching abstraction layer, just annotate heavy methods with @Cacheable. Also, we need to notify our application that methods are cached by annotating our configuration class with @EnableCaching ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access