IBM 6.1.X manual Cache Usage Patterns

Models: 6.1.X

1 97
Download 97 pages 55.38 Kb
Page 66
Image 66
Cache Usage Patterns

Cache Usage Patterns

Most WebSphere Portal caches follow the simple paradigm: if an entry already exists use it, otherwise add the entry. However, there are caches that behave differently. Each cache follows one of the following four patterns:

￿Pattern: regular

The regular pattern, described earlier, is the most common cache pattern:

value = cache.get(key); if (value == null) {

value = calculateNewValue(); cache.put(key, value);

}

￿Pattern: invalidation checking

Invalidating cache entries in a clustered environment is rather expensive. Therefore, portal caches often check whether the entry to be invalidated actually exists in the local cache.

test = cache.get(key); if (test != null) {

cache.invalidate(key);

}

Caches following this pattern follow the regular pattern for all but invalidation actions.

￿Pattern: multiple object types

Most caches hold only a single object type. When caches can hold multiple types, they follow the regular pattern for each of those types.

￿Pattern: cascading object types

This pattern is a special case of the ‘multiple object types’ pattern in that two or more object types that are queried in a certain order are stored in a single cache. There may be one cache hit along with a cache miss on a regular basis.

value = cache.get(keyA);

 

if (value == null) {

 

value = cache.get(keyB);

 

if (value == null) {

 

value = calculateNewValue();

 

cache.put(keyA keyB, value);

// either key could be used

}

 

}

 

6 1

W E BS P HE R E P O R T AL V 6 . 1 T U N I N G G U I D E

Page 66
Image 66
IBM 6.1.X manual Cache Usage Patterns