org.wamblee.cache
Interface Cache<KeyType extends Serializable,ValueType extends Serializable>

All Known Implementing Classes:
EhCache, ForeverCache, ZeroCache

public interface Cache<KeyType extends Serializable,ValueType extends Serializable>

The Cache interface represents a cache intended for application-level caching. In some circumstances it is more optimal to implement caching directly in the code instead of relying on Hibernate caching methods. This interface abstracts from the used cache implementation. Cache implementations must be thread-safe.


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.
 

Method Detail

put

void put(KeyType aKey,
         ValueType aValue)
Adds a key-value pair to the cache.

Parameters:
aKey - Key.
aValue - Value.

get

ValueType get(KeyType aKey)
Retrieves a value from the cache.

Parameters:
aKey - Key to retrieve.
Returns:
Value or null if expired..

remove

void remove(KeyType aKey)
Removes an entry from the cache.

Parameters:
aKey - Key to remove the entry for.

clear

void clear()
Removes all entries from the cache.



Copyright © 2011. All Rights Reserved.