org.sape.carbon.services.cache.mru
Class DefaultMRUCacheImpl

java.lang.Object
  |
  +--org.sape.carbon.services.cache.mru.AbstractMRUCache
        |
        +--org.sape.carbon.services.cache.mru.DefaultMRUCacheImpl
All Implemented Interfaces:
Cache, Configurable, FunctionalInterface, Initializable, Map, MRUCache, Schedulable

public class DefaultMRUCacheImpl
extends AbstractMRUCache

Extends AbsractMRUCache to provide the get method Copyright 2002 Sapient

Since:
carbon 1.0
Version:
$Revision: 1.9 $($Author: dvoet $ / $Date: 2003/05/05 21:21:07 $)
Author:
Doug Voet, April 2002

Field Summary
protected  MRUCacheDataLoader dataLoader
          Holds the loader used to load this cache.
private  org.apache.commons.logging.Log log
          The handle to Apache-commons logger
 
Fields inherited from class org.sape.carbon.services.cache.mru.AbstractMRUCache
cacheHits, cacheMisses, capacity, DEFAULT_ELEMENT_EXPIRATION_INTERVAL, expirationInterval, keyMap, map, MAX_EXPIRATION_TIME, name, ordering
 
Constructor Summary
DefaultMRUCacheImpl()
           
 
Method Summary
 void configure(ComponentConfiguration configuration)
          Configures the component with a MRUCacheConfiguration.
 Object get(Object key)
          For a given key value, return the object associated with the key value from the cache.
 
Methods inherited from class org.sape.carbon.services.cache.mru.AbstractMRUCache
clear, containsKey, containsValue, entrySet, getCacheHits, getCacheMisses, getCapacity, getExpirationInterval, getHitPercentage, getHits, getMisses, getObject, getSize, initialize, isEmpty, keySet, put, putAll, refreshAll, remove, removeLast, runScheduledTask, setCapacity, setExpirationInterval, size, toString, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

dataLoader

protected MRUCacheDataLoader dataLoader
Holds the loader used to load this cache.


log

private org.apache.commons.logging.Log log
The handle to Apache-commons logger

Constructor Detail

DefaultMRUCacheImpl

public DefaultMRUCacheImpl()
Method Detail

configure

public void configure(ComponentConfiguration configuration)
Configures the component with a MRUCacheConfiguration.

Specified by:
configure in interface Configurable
Overrides:
configure in class AbstractMRUCache
Parameters:
configuration - MRUCacheConfiguration used to configure the component.
See Also:
Configurable.configure(ComponentConfiguration)

get

public Object get(Object key)

For a given key value, return the object associated with the key value from the cache. If the value is not found in the cache OR if the value in the cache has expired, the cache will attempt to load it from the DataLoader. If the DataLoader returns a null value, a null value will be stored in the cache and returned to the caller.

Unlike other methods on the MRUCache class, this method is not synchronized at the method level. It is, however, synchronized within the method. The purpose of this is to allow the cache to continue servicing requests while it is loading data from the DataLoader. All other activities in this method are synchronized, but the load of data from the MRUCacheDataLoader is unsycnchronized, and will not stop other threads from reading from the cache, or loading other datums.

Parameters:
key - the key for the desired cache entry
Returns:
Object the cached object


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.