net.dontdrinkandroot.cache.impl.memory
Class MemoryCache<K,V>

java.lang.Object
  extended by net.dontdrinkandroot.cache.impl.AbstractCache<K,V>
      extended by net.dontdrinkandroot.cache.impl.AbstractMapBackedCache<K,V,M>
          extended by net.dontdrinkandroot.cache.impl.AbstractMapBackedCustomTtlCache<K,V,SimpleMetaData>
              extended by net.dontdrinkandroot.cache.impl.memory.MemoryCache<K,V>
All Implemented Interfaces:
Cache<K,V>, CustomTtlCache<K,V>

public class MemoryCache<K,V>
extends AbstractMapBackedCustomTtlCache<K,V,SimpleMetaData>

Author:
Philip W. Sorst

Field Summary
protected  HashMap<K,V> dataMap
           
 
Fields inherited from interface net.dontdrinkandroot.cache.Cache
UNLIMITED_IDLE_TIME
 
Constructor Summary
MemoryCache(String name, long defaultTimeToLive, ExpungeStrategy expungeStrategy)
           
MemoryCache(String name, long defaultTimeToLive, long defaultMaxIdleTime, ExpungeStrategy expungeStrategy)
           
 
Method Summary
protected
<T extends V>
T
copyData(T data)
           
protected  void doDelete(K key, SimpleMetaData metaData)
          Performs deletion of the data belonging to the metadata.
protected
<T extends V>
T
doGet(K key, SimpleMetaData metaData)
          Performs retrieval of the data belonging to the metadata.
protected
<T extends V>
T
doPut(K key, T data, long timeToLive, long maxIdleTime)
          Performs storage of the given data and adds new metadata to the map.
 boolean isCopyOnRead()
           
 boolean isCopyOnWrite()
           
 MemoryCache<K,V> setCopyOnRead(boolean copyOnRead)
           
 MemoryCache<K,V> setCopyOnWrite(boolean copyOnWrite)
           
 
Methods inherited from class net.dontdrinkandroot.cache.impl.AbstractMapBackedCustomTtlCache
doPut, put, put, putWithErrors, putWithErrors
 
Methods inherited from class net.dontdrinkandroot.cache.impl.AbstractMapBackedCache
cleanUp, delete, delete, expunge, get, getEntriesMetaData, getEntriesMetaDataMap, getExpungeStrategy, getMetaData, getStatistics, getWithErrors, put, putWithErrors, setEntriesMetaDataMap, setExpungeStrategy
 
Methods inherited from class net.dontdrinkandroot.cache.impl.AbstractCache
getCleanUpLogger, getDefaultMaxIdleTime, getDefaultTtl, getLogger, getName, setDefaultMaxIdleTime, setDefaultTtl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.dontdrinkandroot.cache.Cache
cleanUp, delete, get, getDefaultMaxIdleTime, getDefaultTtl, getMetaData, getName, getStatistics, getWithErrors, put, putWithErrors
 

Field Detail

dataMap

protected final HashMap<K,V> dataMap
Constructor Detail

MemoryCache

public MemoryCache(String name,
                   long defaultTimeToLive,
                   ExpungeStrategy expungeStrategy)

MemoryCache

public MemoryCache(String name,
                   long defaultTimeToLive,
                   long defaultMaxIdleTime,
                   ExpungeStrategy expungeStrategy)
Method Detail

doPut

protected <T extends V> T doPut(K key,
                                T data,
                                long timeToLive,
                                long maxIdleTime)
                     throws CacheException
Description copied from class: AbstractMapBackedCustomTtlCache
Performs storage of the given data and adds new metadata to the map.

Specified by:
doPut in class AbstractMapBackedCustomTtlCache<K,V,SimpleMetaData>
Throws:
CacheException

doDelete

protected void doDelete(K key,
                        SimpleMetaData metaData)
                 throws CacheException
Description copied from class: AbstractMapBackedCache
Performs deletion of the data belonging to the metadata. Removal from the map is done by the superclass.

Specified by:
doDelete in class AbstractMapBackedCache<K,V,SimpleMetaData>
Throws:
CacheException

doGet

protected <T extends V> T doGet(K key,
                                SimpleMetaData metaData)
                     throws CacheException
Description copied from class: AbstractMapBackedCache
Performs retrieval of the data belonging to the metadata.

Specified by:
doGet in class AbstractMapBackedCache<K,V,SimpleMetaData>
Throws:
CacheException

copyData

protected <T extends V> T copyData(T data)

isCopyOnRead

public boolean isCopyOnRead()

isCopyOnWrite

public boolean isCopyOnWrite()

setCopyOnRead

public MemoryCache<K,V> setCopyOnRead(boolean copyOnRead)

setCopyOnWrite

public MemoryCache<K,V> setCopyOnWrite(boolean copyOnWrite)


Copyright © 2013 dontdrinkandroot. All Rights Reserved.