|
IMC Epclient 5.0.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
A cache is a in memory map of key-value-pairs. The keys are used to identify the cached values.
Keys must not be null and implement the methods equals and hashCode, see class java.lang.Object. Moreover, keys should be immutable. If they are not, keys must not be modified after they have been passed into any method of this class! If you are not sure if you can absolutely correctly fulfill these conditions, please just use java.lang.Strings for all key arguments instead.
Caches come in two flavors. The preferred type is a Transparent Cache. You create a transparent cache if you register a TransparentCacheDescriptor with the CacheManager. With a transparent cache, you usually just call the lookup-method and do not have to worry if the needed object is indeed in the cache or not. If the lookup-method discovers that your requested object is not cached (because it timed out, it had been LRU-evicted or it has not been loaded yet), it loads the object into the cache using the descriptor provided by you at registration time. The cache is called transparent, because the load operation is transparent to you. Either way, if loaded or not, it will return the object requested by you or it will throw an exception if it could not be loaded.
A transparent cache is required to perform entry level synchronization during load operations. If a particular object for key x must be loaded because of a cache miss, threads doing lookups on other keys than x in this cache must not be affected. Threads which also do a lookup on key x are blocked until the object x is loaded.
With a Non Transparent Cache you have to insert the objects yourself and lookup returns null on cache misses.
The implementation of all classes implementing ICache must be thread safe.
The behaviour of the cache in terms of replacement strategies is specified via the associated ICacheDescriptor. A cache may be restricted by size (maximum number of objects in the cache) or by time (maximum number of milliseconds an object may live in the cache) or both. The replacement-strategy is as follows:
| Nested Class Summary | |
static interface |
ICache.IKeyFilter
Is used to filter keys. |
| Method Summary | |
void |
insert(java.lang.Object key,
java.lang.Object value)
Inserts an object for a particular key in the cache. |
java.lang.Object |
lookup(java.lang.Object key)
Looks up the cache for a particular key. |
void |
remove(java.lang.Object key)
Removes a cached object for a particular key. |
void |
removeAll()
Removes all cached objects in this cache. |
void |
removeAllHaving(ICache.IKeyFilter f)
For every key in the cache, method f.accept() is called. |
| Method Detail |
public java.lang.Object lookup(java.lang.Object key)
java.lang.RuntimeException - if this is a transparent cache and a load operation
which is triggered by this method throws an exception.public void remove(java.lang.Object key)
public void removeAll()
public void removeAllHaving(ICache.IKeyFilter f)
f - filter that qualifies keys.
public void insert(java.lang.Object key,
java.lang.Object value)
|
IMC Epclient 5.0.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||