de.intarsys.tools.cache
public class Cache<T> extends java.lang.Object implements ISynchronizable
The cache strategy depends on the samples taken in the CacheEntry.
Constructor and Description |
---|
Cache(int size)
Create a cache with a maximum size of size elements.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all entries in the cache.
|
T |
get(java.lang.Object key)
The object with the key "key" or null.
|
boolean |
isOutOfSynch()
true if the component is out of synch. |
void |
put(java.lang.Object key,
T value)
Store the object "value" with the key "key" in the cache.
|
void |
remove(java.lang.Object key)
Remove an object from the cache.
|
protected void |
removeStrategy()
Perform the "cleanup" of the cache.
|
int |
size()
The actual size of the cache.
|
void |
synch()
Perform a synchronization with the components physical resources.
|
public Cache(int size)
size
- The maximum number of elements held in the cache.public void clear()
public T get(java.lang.Object key)
key
- The key to be used for looking up the cache.public boolean isOutOfSynch()
ISynchronizable
true
if the component is out of synch.isOutOfSynch
in interface ISynchronizable
true
if the component is out of synch.public void put(java.lang.Object key, T value)
key
- The key to use for storing the objectvalue
- The value to put in the cache.public void remove(java.lang.Object key)
key
- protected void removeStrategy()
public int size()
public void synch()
ISynchronizable
In case of a scheduled synchronization this may be called by an external daemon.
synch
in interface ISynchronizable