tuwien.auto.calimero.buffer.cache
Interface Cache

All Known Implementing Classes:
ExpiringCache, LFUCache, PositiveListCache

public interface Cache

Cache interface to use for different caching policies.

Cache entries are unambiguously identified through a key, as defined by CacheObject.
For comparison of keys, Object.hashCode() and Object.equals(Object) are used.

See Also:
CacheObject

Nested Class Summary
static interface Cache.Statistic
          Offers information about data counting and cache performance.
 
Method Summary
 void clear()
          Empties the cache of all CacheObjects.
 CacheObject get(java.lang.Object key)
          Gets the CacheObject associated with key from the cache.
 void put(CacheObject obj)
          Inserts the CacheObject obj into the cache.
 void remove(java.lang.Object key)
          Removes the CacheObject associated with key from the cache, if found.
 void removeExpired()
          Removes all CacheObjects which are not valid anymore, as defined by a caching policy, from the cache.
 Cache.Statistic statistic()
          Returns information collected by this cache since its creation.
 

Method Detail

clear

void clear()
Empties the cache of all CacheObjects.


get

CacheObject get(java.lang.Object key)
Gets the CacheObject associated with key from the cache.

If found, the access count of the CacheObject is incremented by 1.

Parameters:
key - key to search
Returns:
the CacheObject or null if key does not exist in the cache

put

void put(CacheObject obj)
Inserts the CacheObject obj into the cache.

If a CacheObject with an equal key (delivered by CacheObject.getKey()) to obj.getKey() is already in the cache, it will be replaced by obj.
CacheObject.resetTimestamp() is invoked on obj after obj was inserted successfully.

Parameters:
obj - CacheObject to put into the cache

remove

void remove(java.lang.Object key)
Removes the CacheObject associated with key from the cache, if found.

Parameters:
key - key of CacheObject to remove

removeExpired

void removeExpired()
Removes all CacheObjects which are not valid anymore, as defined by a caching policy, from the cache.


statistic

Cache.Statistic statistic()
Returns information collected by this cache since its creation.

Returns:
a Cache.Statistic object