org.wamblee.cache
Class ForeverCache<KeyType extends Serializable,ValueType extends Serializable>

java.lang.Object
  extended by org.wamblee.cache.ForeverCache<KeyType,ValueType>
All Implemented Interfaces:
Cache<KeyType,ValueType>

public class ForeverCache<KeyType extends Serializable,ValueType extends Serializable>
extends Object
implements Cache<KeyType,ValueType>

A very simple cache based on a HashMap, It never expires any entries, and has no bounds on its size.

Author:
Erik Brakkee

Constructor Summary
ForeverCache()
          Constructs the cache.
 
Method Summary
 void clear()
          Removes all entries from the cache.
 ValueType get(KeyType aKey)
          Retrieves a value from the cache.
 void put(KeyType aKey, ValueType aValue)
          Adds a key-value pair to the cache.
 void remove(KeyType aKey)
          Removes an entry from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForeverCache

public ForeverCache()
Constructs the cache.

Method Detail

put

public void put(KeyType aKey,
                ValueType aValue)
Description copied from interface: Cache
Adds a key-value pair to the cache.

Specified by:
put in interface Cache<KeyType extends Serializable,ValueType extends Serializable>
Parameters:
aKey - Key.
aValue - Value.

get

public ValueType get(KeyType aKey)
Description copied from interface: Cache
Retrieves a value from the cache.

Specified by:
get in interface Cache<KeyType extends Serializable,ValueType extends Serializable>
Parameters:
aKey - Key to retrieve.
Returns:
Value or null if expired..

remove

public void remove(KeyType aKey)
Description copied from interface: Cache
Removes an entry from the cache.

Specified by:
remove in interface Cache<KeyType extends Serializable,ValueType extends Serializable>
Parameters:
aKey - Key to remove the entry for.

clear

public void clear()
Description copied from interface: Cache
Removes all entries from the cache.

Specified by:
clear in interface Cache<KeyType extends Serializable,ValueType extends Serializable>


Copyright © 2011. All Rights Reserved.