|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecttuwien.auto.calimero.buffer.cache.ExpiringCache
tuwien.auto.calimero.buffer.cache.LFUCache
public class LFUCache
A Cache using a LFU replacement policy.
The usage value of CacheObject.getUsage() equals the access count,
CacheObject.getCount().
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface tuwien.auto.calimero.buffer.cache.Cache |
|---|
Cache.Statistic |
| Field Summary |
|---|
| Fields inherited from class tuwien.auto.calimero.buffer.cache.ExpiringCache |
|---|
defaultSweepInterval, map, sweepInterval |
| Constructor Summary | |
|---|---|
LFUCache(int cacheSize,
int timeToExpire)
Creates a new LFU cache. |
|
| 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. |
protected void |
notifyRemoved(CacheObject obj)
Override this method to get notified when ExpiringCache.removeExpired() removed a
CacheObject from the ExpiringCache.map. |
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. |
Cache.Statistic |
statistic()
Returns information collected by this cache since its creation. |
| Methods inherited from class tuwien.auto.calimero.buffer.cache.ExpiringCache |
|---|
removeExpired, startSweeper, stopSweeper |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LFUCache(int cacheSize,
int timeToExpire)
Optionally, a maximum cache size and an expiring time can be specified.
cacheSize - maximum number of CacheObjects in the cache, or
0 for no maximumtimeToExpire - time in seconds for cache objects to stay valid,
or 0 for no expiring| Method Detail |
|---|
public void clear()
CacheCacheObjects.
public CacheObject get(java.lang.Object key)
CacheCacheObject associated with key from the
cache.
If found, the access count of the CacheObject is incremented by 1.
key - key to search
null if key does
not exist in the cacheprotected final void notifyRemoved(CacheObject obj)
ExpiringCacheExpiringCache.removeExpired() removed a
CacheObject from the ExpiringCache.map.
notifyRemoved in class ExpiringCacheobj - removed CacheObjectpublic void put(CacheObject obj)
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.
If expiring of cache objects is set, and the timestamp of a
CacheObject is renewed after it has been put into the cache, a
new put(CacheObject) is required for that object to apply the
timestamp and keep the cache in a consistent state.
obj - CacheObject to put into the cachepublic void remove(java.lang.Object key)
Cachekey from the cache,
if found.
key - key of CacheObject to removepublic Cache.Statistic statistic()
Cache
Cache.Statistic object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||