Understanding Caches and Cache Managers
With Terracotta Ehcache, a cache holds elements that are represented as key-value pairs. The key and its value are both Java objects. Keep the following points in mind about key-value pairs in a cache:
A key can be of any type of Java object
except an IS document.
A value can be of any type of Java object.
If you are caching data to
BigMemory or a
Terracotta Server Array, or you write the cache to the local disk store, the objects must be serializable.
Note:
IData implementors are serializable and therefore can be included in a cache as a value. However, the IData itself must contain serializable objects. If the IData to be cached includes non-serializable objects such as streams, XML nodes, or custom objects that are not serializable, Terracotta throws an exception when attempting to write to the cache.
An element that is placed in cache is identified by its key. For example, when Integration Server caches a session object, it uses the session ID as the key. Similarly, when developers create services that put objects into a cache, they select an appropriate identifier to use as the key to retrieve the objects from cache. For example, an application that caches customer objects might derive its key from the customer account number.
A cache has an associated cache manager. A cache manager serves as a container for grouping a set of caches into one “management unit” that you can start and shut down together.
The caches that you associate with a cache manager can have different characteristics and configurations. For example, cache manager XYZ might include one cache that resides entirely on the heap and another that extends to BigMemory.
Although there are many properties that you can configure on a cache-by-cache basis, there are certain properties that you assign at the cache manager level. These include:
The location of the local disk store. All of the caches associated with a cache manager use the same disk store location. If you want two caches to use different local disk stores, then you must create those caches in different cache managers.
The location of the Terracotta Server Array . All of the distributed caches associated with a cache manager use the same
Terracotta Server Array. If you want two caches to use two different
Terracotta Server Arrays, then you must create those caches in different cache managers.
The cache managers that you create on an Integration Server are referred to as public cache managers. Public cache managers (and the caches that they contain) can be used by flow services that your developers build.
For more information about creating and configuring public cache managers and caches, see
Working with Cache Managers and
Working with Caches.