IMC Epclient 5.0.3

at.spardat.enterprise.cache
Class DefaultCache

java.lang.Object
  extended byat.spardat.enterprise.cache.DefaultCache
All Implemented Interfaces:
ICache

public class DefaultCache
extends java.lang.Object
implements ICache

A cache implementation, where the entries are kept in a HashMap. Moreover, each entry is also inserted in two doubly linked list. One specifies the insertion and the other the access-order.


Nested Class Summary
 
Nested classes inherited from class at.spardat.enterprise.cache.ICache
ICache.IKeyFilter
 
Constructor Summary
DefaultCache(ICacheDescriptor descriptor)
          Constructs a Cache and takes the caching behaviour from the provided descriptor.
 
Method Summary
 void checkInvariant()
          The public synchronized version of consistency checking
 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.
static void main(java.lang.String[] args)
           
 void print()
          outputs the cache content and access statistics
 void printStatistics()
          Outputs statistics of cache usage to System.out.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCache

public DefaultCache(ICacheDescriptor descriptor)
Constructs a Cache and takes the caching behaviour from the provided descriptor.

Method Detail

lookup

public java.lang.Object lookup(java.lang.Object key)
Description copied from interface: ICache
Looks up the cache for a particular key.

Specified by:
lookup in interface ICache
Returns:
the found object or null, if there is no object cached for the key. If this is a transparent cache, this method never returns null.
See Also:
ICache.lookup(Object)

remove

public void remove(java.lang.Object key)
Description copied from interface: ICache
Removes a cached object for a particular key. If the cache does not contain an object for the key, this method is a noop.

Specified by:
remove in interface ICache
See Also:
ICache.remove(Object)

removeAll

public void removeAll()
Description copied from interface: ICache
Removes all cached objects in this cache.

Specified by:
removeAll in interface ICache
See Also:
ICache.removeAll()

removeAllHaving

public void removeAllHaving(ICache.IKeyFilter f)
Description copied from interface: ICache
For every key in the cache, method f.accept() is called. If it returns true, the object is removed from the cache.

Specified by:
removeAllHaving in interface ICache
Parameters:
f - filter that qualifies keys.
See Also:
ICache.removeAllHaving(at.spardat.enterprise.cache.ICache.IKeyFilter)

insert

public void insert(java.lang.Object key,
                   java.lang.Object value)
Description copied from interface: ICache
Inserts an object for a particular key in the cache. If the cache already contained an object for the key, it is replaced. This method must not be called for transparent caches.

Specified by:
insert in interface ICache
See Also:
ICache.insert(Object,Object)

checkInvariant

public void checkInvariant()
The public synchronized version of consistency checking


print

public void print()
outputs the cache content and access statistics


printStatistics

public void printStatistics()
Outputs statistics of cache usage to System.out. Just for development phase. Do not call this method in production environments.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

IMC Epclient 5.0.3