com.spoledge.audao.db.dao
Class ExpiringMemoryDtoCacheImpl<K,V>

java.lang.Object
  extended by com.spoledge.audao.db.dao.ExpiringMemoryDtoCacheImpl<K,V>
All Implemented Interfaces:
DtoCache<K,V>

public class ExpiringMemoryDtoCacheImpl<K,V>
extends java.lang.Object
implements DtoCache<K,V>

Expiring Memory DtoCache uses LinkedHashMap to store the values (LRU cache). The cached objects expires.


Nested Class Summary
protected static class ExpiringMemoryDtoCacheImpl.Entry<V>
           
protected  class ExpiringMemoryDtoCacheImpl.LHM<K,E>
           
 
Field Summary
protected  long expireMillis
           
protected  ExpiringMemoryDtoCacheImpl.LHM<K,ExpiringMemoryDtoCacheImpl.Entry<V>> map
           
protected  int maxSize
           
 
Constructor Summary
ExpiringMemoryDtoCacheImpl(long expireMillis, int maxSize)
           
ExpiringMemoryDtoCacheImpl(long expireMillis, int maxSize, int initialCapacity, float loadFactor)
           
 
Method Summary
 void clear()
          Clears the cache.
protected  ExpiringMemoryDtoCacheImpl.LHM<K,ExpiringMemoryDtoCacheImpl.Entry<V>> createMap(int initialCapacity, float loadFactor)
           
 V get(K key)
          Returns the associated object or null.
 void put(K key, V value)
          Puts the key/value pair into the cache.
 void remove(K key)
          Removes the associated object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

expireMillis

protected final long expireMillis

maxSize

protected final int maxSize

map

protected final ExpiringMemoryDtoCacheImpl.LHM<K,ExpiringMemoryDtoCacheImpl.Entry<V>> map
Constructor Detail

ExpiringMemoryDtoCacheImpl

public ExpiringMemoryDtoCacheImpl(long expireMillis,
                                  int maxSize)

ExpiringMemoryDtoCacheImpl

public ExpiringMemoryDtoCacheImpl(long expireMillis,
                                  int maxSize,
                                  int initialCapacity,
                                  float loadFactor)
Method Detail

get

public final V get(K key)
Returns the associated object or null.

Specified by:
get in interface DtoCache<K,V>

put

public final void put(K key,
                      V value)
Puts the key/value pair into the cache.

Specified by:
put in interface DtoCache<K,V>

remove

public final void remove(K key)
Removes the associated object.

Specified by:
remove in interface DtoCache<K,V>

clear

public final void clear()
Clears the cache.

Specified by:
clear in interface DtoCache<K,V>

createMap

protected ExpiringMemoryDtoCacheImpl.LHM<K,ExpiringMemoryDtoCacheImpl.Entry<V>> createMap(int initialCapacity,
                                                                                          float loadFactor)


Copyright © 2010 Spolecne s.r.o. All Rights Reserved.