com.waveset.util
Class SoftCache

java.lang.Object
  extended bycom.waveset.util.SoftCache

public class SoftCache
extends java.lang.Object

A cache that stores items using normal Java references while the item is active (i.e. it is being retrieved frequently). When the item has not been retrieved for the specified interval, the hard reference is cleared, but a SoftReference is retained. If the object is retrieved while it's in the soft cache, then it's moved back to the hard cache. This cache is intended for large items that are expensive to recompute.


Field Summary
 java.util.Map _evictionDates
          Holds Dates when items in _hardCache should be moved to _softCache
 java.util.Map _hardCache
          Hard references to items that have been retrieved recently.
 long _msBeforeEviction
          Milliseconds of idleness before moving an item from _hardCache to _softCache.
 java.util.Map _softCache
          SoftReferences to items that haven't been referenced in at least _msBeforeEviction milliseconds.
static java.lang.String code_id
           
 
Constructor Summary
SoftCache(long msBeforeEviction)
           
 
Method Summary
 java.lang.Object get(java.lang.Object key)
           
 void put(java.lang.Object key, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

_hardCache

public final java.util.Map _hardCache
Hard references to items that have been retrieved recently.


_softCache

public final java.util.Map _softCache
SoftReferences to items that haven't been referenced in at least _msBeforeEviction milliseconds. We still keep SoftReferences because we want to keep them around as long as we have the memory.


_evictionDates

public final java.util.Map _evictionDates
Holds Dates when items in _hardCache should be moved to _softCache


_msBeforeEviction

public long _msBeforeEviction
Milliseconds of idleness before moving an item from _hardCache to _softCache.

Constructor Detail

SoftCache

public SoftCache(long msBeforeEviction)
Method Detail

get

public java.lang.Object get(java.lang.Object key)

put

public void put(java.lang.Object key,
                java.lang.Object value)