org.opendoors.cache.immutable
Class CacheImpl

java.lang.Object
  |
  +--org.opendoors.cache.immutable.CacheImpl
All Implemented Interfaces:
Cache, UpdateableCache

public class CacheImpl
extends java.lang.Object
implements UpdateableCache

Implements the updateable cache interface according to the immutable / mutable cache strategy of VFC.


Field Summary
static int AccessCount
          The total number of accesses to the cache.
static int AccessFaultCount
          The total number of access faults returning null.
static int ImmutableHitCount
          The total number of access hits to the immutable cache
static int MutableHitCount
          The total number of access hits to the mutable cache.
 
Method Summary
 java.lang.Object get(java.lang.Object argument)
          Gets a value from the immutable cache.
 long[] getMetrics()
          Returns the metrics in the following order:
 void invalidate(java.lang.Object argument)
          Invalidates an object in the cache by removing it from the mutable cache.
 void invalidateAll()
          Invalidates the entire cache.
 java.lang.Object[] keys()
          Returns the keys of the cache as an array.
 void put(java.lang.Object argument, java.lang.Object value)
          Puts an object into the cache by enqueueing it on the immutable cache using the change control delegate.
 void update()
          Allows for the cache to be explicitly updated.
 java.lang.Object[] values()
          Returns the elements in the cache as an array using the current image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AccessCount

public static final int AccessCount
The total number of accesses to the cache.

ImmutableHitCount

public static final int ImmutableHitCount
The total number of access hits to the immutable cache

MutableHitCount

public static final int MutableHitCount
The total number of access hits to the mutable cache.

AccessFaultCount

public static final int AccessFaultCount
The total number of access faults returning null.
Method Detail

get

public java.lang.Object get(java.lang.Object argument)
Gets a value from the immutable cache.

Note: this implementation will also search the mutable cache if the element is not found in the mutable cache.

Specified by:
get in interface Cache
Parameters:
argument - The key to the element in the cache.

getMetrics

public long[] getMetrics()
Returns the metrics in the following order:
 [0] The total number of gets, accesses.
 [1] The number of accesses which resulted in a hit to the immutable cache.
 [2] The number of accesses which resulted in a hit to the mutable cache.
 [3] The number of accesses which resulted in a fault and a need to
 regenerate the cache entry.
 

values

public java.lang.Object[] values()
Returns the elements in the cache as an array using the current image.
Specified by:
values in interface Cache

keys

public java.lang.Object[] keys()
Returns the keys of the cache as an array.
Specified by:
keys in interface Cache

invalidate

public void invalidate(java.lang.Object argument)
Invalidates an object in the cache by removing it from the mutable cache. On the next regeneration, this element will no longer be in the cache.
Specified by:
invalidate in interface Cache
Parameters:
argument - The key to the element in the cache.

invalidateAll

public void invalidateAll()
Invalidates the entire cache.
Specified by:
invalidateAll in interface Cache

put

public void put(java.lang.Object argument,
                java.lang.Object value)
Puts an object into the cache by enqueueing it on the immutable cache using the change control delegate.
Specified by:
put in interface Cache
Parameters:
argument - The key to the element in the cache.
value - The element to place into the cache.

update

public void update()
Allows for the cache to be explicitly updated.
Specified by:
update in interface UpdateableCache