mondrian.rolap.cache
Class SoftSmartCache<K,V>

java.lang.Object
  extended by mondrian.rolap.cache.SoftSmartCache<K,V>
All Implemented Interfaces:
Iterable<Map.Entry<K,V>>, SmartCache<K,V>

public class SoftSmartCache<K,V>
extends Object
implements SmartCache<K,V>

A map with soft references that is cleaned up in regular intervals.

There is no contains(key) method because it makes no sense - after contains() returns true, the garbage collector may remove the value that was contained. Instead the code should call get() and keep a reference to the value to prevent garbage collection.

Since:
Nov 3, 2005
Author:
av
 

Nested Class Summary
(package private)  class SoftSmartCache.CacheReference
          an entry in the cache that contains the key for the cache map to remove the entry when its value has been garbage collected
 
Constructor Summary
SoftSmartCache()
           
 
Method Summary
 void clear()
           
 V get(K key)
           
 Iterator<Map.Entry<K,V>> iterator()
           
 V put(K key, V value)
          Places a key/value pair into the queue.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoftSmartCache

public SoftSmartCache()
Method Detail

put

public V put(K key,
             V value)
Description copied from interface: SmartCache
Places a key/value pair into the queue.

Specified by:
put in interface SmartCache<K,V>
Parameters:
key - Key
value - Value
Returns:
the previous value of key or null

get

public V get(K key)
Specified by:
get in interface SmartCache<K,V>

clear

public void clear()
Specified by:
clear in interface SmartCache<K,V>

size

public int size()
Specified by:
size in interface SmartCache<K,V>

iterator

public Iterator<Map.Entry<K,V>> iterator()
Specified by:
iterator in interface Iterable<Map.Entry<K,V>>

SourceForge.net_Logo