Spring cache vs. cachemanger
Spring framework recently introduced caching abstraction with org.springframework.cache.CacheManager
central interface. This interface has few built-in implementations, including:
ConcurrentMapCacheManager
EhCacheCacheManager
NoOpCacheManager
SimpleCacheManager
This design allows you to switch caching library without touching application code. As you can see one of these built-in implementations is backed by EhCache. However notice that EhCacheCacheManager
is just a bridge between Spring caching abstraction and EhCache library. Thus it needs existing net.sf.ehcache.CacheManager
. You can either create an instance of this cache manager yourself or take advantage of existing factory bean, namely EhCacheManagerFactoryBean
.
I understand it's confusing because of overlapping names, but it should be clear from the above which classes come from which library and why are they used.