intarsys runtime library

de.intarsys.tools.cache
Class Cache

java.lang.Object
  extended by de.intarsys.tools.cache.Cache
All Implemented Interfaces:
ISynchronizable

public class Cache
extends Object
implements ISynchronizable

A very simple cache implementation. The cache supports "null"entries.

The cache strategy depends on the samples taken in the CacheEntry.


Constructor Summary
Cache(int size)
          Create a cache with a maximum size of size elements.
 
Method Summary
 void clear()
          Clear all entries in the cache.
 Object get(Object key)
          The object with the key "key" or null.
 boolean isOutOfSynch()
          true if the component is out of synch.
 void put(Object key, Object value)
          Store the object "value" with the key "key" in the cache.
 void remove(Object key)
          Remove an object from the cache.
 int size()
          The actual size of the cache.
 void synch()
          Perform a synchronization with the components physical resources.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cache

public Cache(int size)
Create a cache with a maximum size of size elements.

Parameters:
size - The maximum number of elements held in the cache.
Method Detail

clear

public void clear()
Clear all entries in the cache.


get

public Object get(Object key)
The object with the key "key" or null.

Parameters:
key - The key to be used for looking up the cache.
Returns:
The object with the key "key" or null.

isOutOfSynch

public boolean isOutOfSynch()
Description copied from interface: ISynchronizable
true if the component is out of synch.

Specified by:
isOutOfSynch in interface ISynchronizable
Returns:
true if the component is out of synch.

put

public void put(Object key,
                Object value)
Store the object "value" with the key "key" in the cache.

Parameters:
key - The key to use for storing the object
value - The value to put in the cache.

remove

public void remove(Object key)
Remove an object from the cache.

Parameters:
key -

size

public int size()
The actual size of the cache.

Returns:
The actual size of the cache.

synch

public void synch()
Description copied from interface: ISynchronizable
Perform a synchronization with the components physical resources.

In case of a scheduled synchronization this may be called by an external daemon.

Specified by:
synch in interface ISynchronizable

intarsys runtime library

Copyright © 2008 intarsys consulting GmbH. All Rights Reserved.