JSR-107 (JCache)
API: javax.cache
JCache entities:
[Caching] getCachingProvider, getCache
CachingProvider getCacheManager, close...
CacheManager createCache, destroyCache, getCache...
Cache put[All], containsKey, get[All], replace,
remove[All]
Entry getKey, getValue
Spring Cache
@EnableCaching enable caching
@Cacheable cache first, invoke method if not found
@CachePut invoke method, put into cache
@CacheEvict drop from cache, invoke method
@Caching combine different annotations
@CacheConfig cache configuration
Spring 4.1+ vs JSR-107
@Cacheable @CacheResult
@CachePut @CachePut (@CacheValue)
@CacheEvict @CacheRemove
@CacheEvict(allEntries = true) @CacheRemoveAll
@CacheConfig @CacheDefaults
@EnableCaching + JSR-107 API
+ spring-context-support
Cache providers features
Local/Distrib. Non-blocking JCache Spring
● Cache2k L - + +
● Caffeine L + + +
● Coherence Community Edition + + + -
● EhCache L - + +
● Geode + - - +
● Guava L - - -
● Hazelcast + + + +
● Ignite + + + +
● Infinispan + + + +
● JCS + - + -
● Redisson (non-Pro) D + + +
Spring supported providers
Cache2k Caffeine
Couchbase EhCache 2.x
Hazelcast Infinispan
Redisson
JCache (JSR-107) – EhCache 3, Hazelcast, Infinispan etc.
Simple None
https://docs.spring.io/spring-boot/docs/current/reference/html/io.html#io.caching.provider
References
DZone Java Caching – https://dzone.com/refcardz/java-caching
A Java Geek Choosing a cache, A list of cache providers –
https://blog.frankel.ch/tag/cache/
Baeldung A Guide To Caching in Spring –
https://www.baeldung.com/spring-cache-tutorial
java T point Spring Boot Caching –
https://www.javatpoint.com/spring-boot-caching
Java Design Patterns – Caching –
https://java-design-patterns.com/patterns/caching/
etc.

Java Caching

  • 2.
    JSR-107 (JCache) API: javax.cache JCacheentities: [Caching] getCachingProvider, getCache CachingProvider getCacheManager, close... CacheManager createCache, destroyCache, getCache... Cache put[All], containsKey, get[All], replace, remove[All] Entry getKey, getValue
  • 3.
    Spring Cache @EnableCaching enablecaching @Cacheable cache first, invoke method if not found @CachePut invoke method, put into cache @CacheEvict drop from cache, invoke method @Caching combine different annotations @CacheConfig cache configuration
  • 4.
    Spring 4.1+ vsJSR-107 @Cacheable @CacheResult @CachePut @CachePut (@CacheValue) @CacheEvict @CacheRemove @CacheEvict(allEntries = true) @CacheRemoveAll @CacheConfig @CacheDefaults @EnableCaching + JSR-107 API + spring-context-support
  • 5.
    Cache providers features Local/Distrib.Non-blocking JCache Spring ● Cache2k L - + + ● Caffeine L + + + ● Coherence Community Edition + + + - ● EhCache L - + + ● Geode + - - + ● Guava L - - - ● Hazelcast + + + + ● Ignite + + + + ● Infinispan + + + + ● JCS + - + - ● Redisson (non-Pro) D + + +
  • 6.
    Spring supported providers Cache2kCaffeine Couchbase EhCache 2.x Hazelcast Infinispan Redisson JCache (JSR-107) – EhCache 3, Hazelcast, Infinispan etc. Simple None https://docs.spring.io/spring-boot/docs/current/reference/html/io.html#io.caching.provider
  • 7.
    References DZone Java Caching– https://dzone.com/refcardz/java-caching A Java Geek Choosing a cache, A list of cache providers – https://blog.frankel.ch/tag/cache/ Baeldung A Guide To Caching in Spring – https://www.baeldung.com/spring-cache-tutorial java T point Spring Boot Caching – https://www.javatpoint.com/spring-boot-caching Java Design Patterns – Caching – https://java-design-patterns.com/patterns/caching/ etc.