Terracotta Ehcache 10.1 | Ehcache API Developer Guide | Caching Basics | Comparison of CacheManager to UserManagedCache
 
Comparison of CacheManager to UserManagedCache
The first step is to create an instance that manages a cache, and the second step is to create the cache itself.
There are two variations of managing a cache:
By means of a CacheManager
or ...
By means of a UserManagedCache
The decision when to use either the standard CacheManager or the 'lightweight' UserManagedCache depends on the particular use case, since each approach has pros and cons:
CacheManager
Pros:
Offers numerous standard services out of the box - a good starting point for setting up the basic framework.
Cons:
Brings along a certain level of richness and complexity that in some cases might offer more than needed.
UserManagedCache
Pros:
Offers a lightweight approach for examples such as Method local caches, thread local caches, and a cache lifecycle shorter than the application lifecycle.
Cons:
Does not offer out-of-the-box services, which must be configured on-instance basis.
A CacheManager can be created using either Ehcache directly or the JSR 107 JCACHE - Java Temporary Caching API.
Programmatically configuring the instance of a CacheManager and its cache can be done either in Java or via XML.

Copyright © 2010-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release