lazyj.cache
Interface CacheElement<K,V>

Type Parameters:
K - key type
V - value type
All Known Implementing Classes:
ExpirationCache, GenericLastValuesCache, GenericQueryCacher, PageCache

public interface CacheElement<K,V>

An interface that must be implemented by any object that must be registered into the Cache.

Since:
2006-10-03
Author:
costing

Method Summary
 V get(K key)
          The cached entry is most probably a hash of some sort.
 int getRefreshTime()
          The desired refresh time, in seconds.
 void refresh()
          Update the contents of the cache entry.
 

Method Detail

getRefreshTime

int getRefreshTime()
The desired refresh time, in seconds. After this much time from the previous update, the refresh() method is called.

Returns:
the number of seconds between the calls to refresh()

refresh

void refresh()
Update the contents of the cache entry. The implementation is application-dependent. Typically it involves filling an internal hash with some values from the database. But it can do whatever operation here, even something that doesn't involve actually caching anything, but just to execute a periodic task (cron style).


get

V get(K key)
The cached entry is most probably a hash of some sort. This is why the get() method is specified in this interface, to provide an easy and uniform way of retrieving the data between all the implementations.

Parameters:
key - some unique key
Returns:
the value associated with that key, if any, or null.