
上QQ阅读APP看书,第一时间看更新
Caching
We have seen how to improve our application's performance with the use of caching. The following are the best practices to be followed when implementing caching in Spring:
- Spring cache annotations should be used on concrete classes and not on interfaces. If we choose to use proxy-target-class="true", caching will not work because the Java annotation from the interfaces cannot be inherited.
- Try not use @Cacheable and @CachePut together on the same method.
- Do not cache very low-level methods close, such as CPU-intensive and in-memory computations. Spring's caching might be overkill in those scenarios.