net.dontdrinkandroot.cache.impl.memory

## Class MemoryCache<K,V>

- java.lang.Object
- - net.dontdrinkandroot.cache.impl.AbstractCache<K,V>
  - - net.dontdrinkandroot.cache.impl.AbstractMapBackedCache<K,V,M>
    - - net.dontdrinkandroot.cache.impl.AbstractMapBackedCustomTtlCache<K,V,SimpleMetaData>
      - - 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 <philip@sorst.net>

### Field Summary

Fields
`protected HashMap<K,V>` `dataMap`

### Fields inherited from interface net.dontdrinkandroot.cache.Cache

`UNLIMITED_IDLE_TIME`

### Constructor Summary

Constructors
Constructor and Description
`MemoryCache(String name, long defaultTimeToLive, ExpungeStrategy expungeStrategy)`
`MemoryCache(String name, long defaultTimeToLive, long defaultMaxIdleTime, ExpungeStrategy expungeStrategy)`

### Method Summary

Methods
`protected V` `copyData(V data)`
`protected void` `doDelete(K key, SimpleMetaData metaData)` Performs deletion of the data belonging to the metadata.
`protected V` `doGet(K key, SimpleMetaData metaData)` Performs retrieval of the data belonging to the metadata.
`protected V` `doPut(K key, V 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`

### Methods inherited from class net.dontdrinkandroot.cache.impl.AbstractMapBackedCache

`cleanUp, delete, delete, expunge, get, getEntriesMetaData, getEntriesMetaDataMap, getExpungeStrategy, getMetaData, getStatistics, put, 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, put`

### 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 V doPut(K key,
          V 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 V 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 V copyData(V 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)