JSR-107 caching annotations

JSR-107 aims to standardize caching annotations. Listed here are some of the important JSR-107 annotations:

  • @CacheResult: Similar to @Cacheable
  • @CacheRemove: Similar to @CacheEvict; ;@CacheRemove supports conditional eviction if an exception occurs
  • @CacheRemoveAll: Similar to @CacheEvict(allEntries=true); used to remove all entries from the cache

JSR-107 and Spring's caching annotations are fairly similar in terms of the features they offer. Either of them is a good choice. We lean slightly toward JSR-107 because it's a standard. However, make sure you are not using both in the same project.

Get Mastering Spring 5.0 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.