decaf::util::LRUCache< K, V, HASHCODE > Class Template Reference

A Basic Least Recently Used (LRU) Cache Map. More...

#include <src/main/decaf/util/LRUCache.h>

Inheritance diagram for decaf::util::LRUCache< K, V, HASHCODE >:
Inheritance graph
[legend]

Public Member Functions

 LRUCache ()
 Default constructor for an LRU Cache The default capacity is 10000.
 LRUCache (int maximumCacheSize)
 Constructs a LRUCache with a maximum capacity.
 LRUCache (int initialCapacity, int maximumCacheSize, float loadFactor, bool accessOrder)
 Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize, load factor and ordering mode.
virtual ~LRUCache ()
int getMaxCacheSize () const
 Gets the currently configured Max Cache Size setting.
void setMaxCacheSize (int size)
 Sets the maximum size allowed for this LRU Cache.

Protected Member Functions

virtual bool removeEldestEntry (const MapEntry< K, V > &eldest DECAF_UNUSED)

Protected Attributes

int maxCacheSize

Detailed Description

template<typename K, typename V, typename HASHCODE = HashCode<K>>
class decaf::util::LRUCache< K, V, HASHCODE >

A Basic Least Recently Used (LRU) Cache Map.

This LRUCache implements the LinkedHashMap class so all the standard Map operations are provided. When the sive of this LRUCache map exceeds the specified maxCacheSize value then by default the oldest entry is evicted from the Cache.

Subclasses can override the LinkedHashMap::onEviction method to perform custom cache eviction processing.

Since:
1.0

Constructor & Destructor Documentation

template<typename K , typename V , typename HASHCODE = HashCode<K>>
decaf::util::LRUCache< K, V, HASHCODE >::LRUCache (  )  [inline]

Default constructor for an LRU Cache The default capacity is 10000.

template<typename K , typename V , typename HASHCODE = HashCode<K>>
decaf::util::LRUCache< K, V, HASHCODE >::LRUCache ( int  maximumCacheSize  )  [inline]

Constructs a LRUCache with a maximum capacity.

Parameters:
maximumCacheSize The maximum number of cached entries before eviction begins.
template<typename K , typename V , typename HASHCODE = HashCode<K>>
decaf::util::LRUCache< K, V, HASHCODE >::LRUCache ( int  initialCapacity,
int  maximumCacheSize,
float  loadFactor,
bool  accessOrder 
) [inline]

Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize, load factor and ordering mode.

Parameters:
initialCapacity The initial capacity of the LRUCache.
maximumCacheSize The maximum number of cached entries before eviction begins.
loadFactor the load factor. The initial load factor for this LRUCache.
accessOrder The ordering mode - true for access-order, false for insertion-order.
Exceptions:
IllegalArgumentException if the initial capacity is negative or the load factor is non-positive.
template<typename K , typename V , typename HASHCODE = HashCode<K>>
virtual decaf::util::LRUCache< K, V, HASHCODE >::~LRUCache (  )  [inline, virtual]

Member Function Documentation

template<typename K , typename V , typename HASHCODE = HashCode<K>>
int decaf::util::LRUCache< K, V, HASHCODE >::getMaxCacheSize (  )  const [inline]

Gets the currently configured Max Cache Size setting.

Returns:
the current max cache size value.

References decaf::util::LRUCache< K, V, HASHCODE >::maxCacheSize.

template<typename K , typename V , typename HASHCODE = HashCode<K>>
virtual bool decaf::util::LRUCache< K, V, HASHCODE >::removeEldestEntry ( const MapEntry< K, V > &eldest  DECAF_UNUSED  )  [inline, protected, virtual]
template<typename K , typename V , typename HASHCODE = HashCode<K>>
void decaf::util::LRUCache< K, V, HASHCODE >::setMaxCacheSize ( int  size  )  [inline]

Sets the maximum size allowed for this LRU Cache.

Parameters:
size The new maximum cache size setting.
Exceptions:
IllegalArgumentException is size is less than or equal to zero.

References decaf::util::LRUCache< K, V, HASHCODE >::maxCacheSize.


Field Documentation

template<typename K , typename V , typename HASHCODE = HashCode<K>>
int decaf::util::LRUCache< K, V, HASHCODE >::maxCacheSize [protected]

The documentation for this class was generated from the following file:

Generated on 1 Dec 2014 for activemq-cpp-3.8.2 by  doxygen 1.6.1