Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.elexis.data.cache
Class SoftCache<K>

java.lang.Object
  extended by ch.elexis.data.cache.SoftCache<K>
All Implemented Interfaces:
IPersistentObjectCache<K>

public class SoftCache<K>
extends java.lang.Object
implements IPersistentObjectCache<K>

A Cache with soft references and optional expiring items The cache keeps count on numbes of items that are added, removed or expired and can display its statistic

Author:
Gerry

Nested Class Summary
 class SoftCache.CacheEntry
           
 
Constructor Summary
SoftCache()
           
SoftCache(int num)
           
SoftCache(int num, float load)
           
 
Method Summary
 void clear()
           
 java.lang.Object get(K key)
          retrieve a previously inserted object
 void purge()
          Expire and remove all Objects (without removing the SoftReferences, to avoid ConcurrentModificationExceptions)
 void put(K key, java.lang.Object object, int timeToCacheInSeconds)
          Insert an Object that will stay until it is manually removed, or memory gets low, or at most for ICacheable#getCacheTime seconds
 void remove(K key)
           
 void reset()
          completely delete cache
 void stat()
          write statistics to log
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoftCache

public SoftCache()

SoftCache

public SoftCache(int num,
                 float load)

SoftCache

public SoftCache(int num)
Method Detail

put

public void put(K key,
                java.lang.Object object,
                int timeToCacheInSeconds)
Description copied from interface: IPersistentObjectCache
Insert an Object that will stay until it is manually removed, or memory gets low, or at most for ICacheable#getCacheTime seconds

Specified by:
put in interface IPersistentObjectCache<K>

get

public java.lang.Object get(K key)
Description copied from interface: IPersistentObjectCache
retrieve a previously inserted object

Specified by:
get in interface IPersistentObjectCache<K>
Returns:
the object or null, if the object was expired or removed bei the garbage collector.

remove

public void remove(K key)
Specified by:
remove in interface IPersistentObjectCache<K>

clear

public void clear()
Specified by:
clear in interface IPersistentObjectCache<K>

stat

public void stat()
Description copied from interface: IPersistentObjectCache
write statistics to log

Specified by:
stat in interface IPersistentObjectCache<K>

purge

public void purge()
Description copied from interface: IPersistentObjectCache
Expire and remove all Objects (without removing the SoftReferences, to avoid ConcurrentModificationExceptions)

Specified by:
purge in interface IPersistentObjectCache<K>

reset

public void reset()
Description copied from interface: IPersistentObjectCache
completely delete cache

Specified by:
reset in interface IPersistentObjectCache<K>

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis