ehcache

net.sf.ehcache.constructs.readthrough
Class ReadThroughCache

java.lang.Object
  extended by net.sf.ehcache.constructs.EhcacheDecoratorAdapter
      extended by net.sf.ehcache.constructs.readthrough.ReadThroughCache
All Implemented Interfaces:
Cloneable, Ehcache, InternalEhcache

public class ReadThroughCache
extends EhcacheDecoratorAdapter

This class implements the simplest of all possible read through cache behaviors, where a call the get() will delegate to a call to getWithLoader(). This means that a get() call can take a long time; beware. It also does no more locking than Cache.java implements; each separate cache may try to load a key at the same time.

Author:
cschanck

Field Summary
 
Fields inherited from class net.sf.ehcache.constructs.EhcacheDecoratorAdapter
underlyingCache
 
Constructor Summary
ReadThroughCache(Ehcache underlyingCache, ReadThroughCacheConfiguration config)
           
 
Method Summary
 Element get(Object key)
          Gets an element from the cache.
 Element get(Serializable key)
          Gets an element from the cache.
 String getName()
          Gets the cache name.
 
Methods inherited from class net.sf.ehcache.constructs.EhcacheDecoratorAdapter
acquireReadLockOnKey, acquireWriteLockOnKey, addPropertyChangeListener, bootstrap, calculateInMemorySize, calculateOffHeapSize, calculateOnDiskSize, clone, createQuery, disableDynamicFeatures, dispose, evictExpiredElements, flush, getAll, getAllWithLoader, getBootstrapCacheLoader, getCacheConfiguration, getCacheEventNotificationService, getCacheExceptionHandler, getCacheManager, getDiskStoreSize, getGuid, getInternalContext, getKeys, getKeysNoDuplicateCheck, getKeysWithExpiryCheck, getMemoryStoreSize, getOffHeapStoreSize, getQuiet, getQuiet, getRegisteredCacheExtensions, getRegisteredCacheLoaders, getRegisteredCacheWriter, getSearchAttribute, getSearchAttributes, getSize, getStatistics, getStatus, getWithLoader, getWriterManager, hasAbortedSizeOf, initialise, isClusterBulkLoadEnabled, isClusterCoherent, isDisabled, isElementInMemory, isElementInMemory, isElementOnDisk, isElementOnDisk, isExpired, isKeyInCache, isNodeBulkLoadEnabled, isNodeCoherent, isReadLockedByCurrentThread, isSearchable, isValueInCache, isWriteLockedByCurrentThread, load, loadAll, put, put, putAll, putIfAbsent, putIfAbsent, putQuiet, putWithWriter, recalculateSize, registerCacheExtension, registerCacheLoader, registerCacheWriter, registerDynamicAttributesExtractor, releaseReadLockOnKey, releaseWriteLockOnKey, remove, remove, remove, remove, removeAll, removeAll, removeAll, removeAll, removeAndReturnElement, removeElement, removePropertyChangeListener, removeQuiet, removeQuiet, removeWithWriter, replace, replace, setBootstrapCacheLoader, setCacheExceptionHandler, setCacheManager, setDisabled, setName, setNodeBulkLoadEnabled, setNodeCoherent, setTransactionManagerLookup, toString, tryReadLockOnKey, tryWriteLockOnKey, unregisterCacheExtension, unregisterCacheLoader, unregisterCacheWriter, waitUntilClusterBulkLoadComplete, waitUntilClusterCoherent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadThroughCache

public ReadThroughCache(Ehcache underlyingCache,
                        ReadThroughCacheConfiguration config)
Parameters:
underlyingCache -
config -
Method Detail

get

public Element get(Object key)
            throws IllegalStateException,
                   CacheException
Description copied from class: EhcacheDecoratorAdapter
Gets an element from the cache. Updates Element Statistics

Note that the Element's lastAccessTime is always the time of this get. Use Ehcache.getQuiet(Object) to peek into the Element to see its last access time with get

Specified by:
get in interface Ehcache
Overrides:
get in class EhcacheDecoratorAdapter
Parameters:
key - an Object value
Returns:
the element, or null, if it does not exist.
Throws:
IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException
See Also:
Ehcache.isExpired(net.sf.ehcache.Element)

get

public Element get(Serializable key)
            throws IllegalStateException,
                   CacheException
Description copied from class: EhcacheDecoratorAdapter
Gets an element from the cache. Updates Element Statistics

Note that the Element's lastAccessTime is always the time of this get. Use Ehcache.getQuiet(Object) to peak into the Element to see its last access time with get

Specified by:
get in interface Ehcache
Overrides:
get in class EhcacheDecoratorAdapter
Parameters:
key - a serializable value
Returns:
the element, or null, if it does not exist.
Throws:
IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException
See Also:
Ehcache.isExpired(net.sf.ehcache.Element)

getName

public String getName()
Description copied from class: EhcacheDecoratorAdapter
Gets the cache name.

Specified by:
getName in interface Ehcache
Overrides:
getName in class EhcacheDecoratorAdapter

ehcache

Copyright 2001-2017, Terracotta, Inc.