Cache Regions

Use

The cache user’s view of the CML is represented by cache regions. A cache region is a named entity that provides a single distinct namespace for cached objects, isolation of operations over cached objects and separate configuration. Each cache region has a single storage plug-in and a single eviction policy plug-in associated with it, as well as separate cache threshold values.

Features

A cache region can contain multiple cache groups that are defined by the cache user. There is always a default cache group for each cache region. Cache groups are identified by their name and are usually used to group together objects on which a cache user can perform massive operations. If the user does not request a specific cache group, he or she always works with the default one (accessed by a cache faзade).

Cache Region Structure

Activities

The general action flow when working with the cache is the following:

...

       1.      The cache user gets a cache region using a RegionFactory.

       2.      The cache user accesses the default cache group through the cache faзade, or a different cache group using its name.

       3.      The cache user performs operations on the cached objects (create, put, remove and so on).

       4.      The cache group uses the storage plug-in that is bound to the cache region to find the appropriate object on which the operation should be performed.

       5.      The storage plug-in contacts the eviction policy plug-in about the operation being performed on the object so that the latter can determine which objects are to be removed if this is needed.

The eviction policy plug-in that is associated with the cache region can evict cached objects periodically if a certain threshold (cache size or cache objects count) is exceeded.

Notification of a Cache Object’s Invalidation

Applications can register invalidation listeners to receive notification when a cached object is invalidated and removed from the cache. These listeners are registered in a special entity, called the cache control, that pertains to the cache region. This mechanism works in both cases:

·        When the application explicitly invalidated an object in the cache using the cache control entity

·        When the applications invalidates an object using the cache faзade (or another cache group).