|
|||||||||
| 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.PositiveListCache
public class PositiveListCache
A static Cache using a positive list with allowed keys for the cache.
The positive list contains key objects which are allowed to be cached. On a
put(CacheObject) operation, CacheObject.getKey() is checked for a
positive match in that list in order to be allowed for caching.
This cache does not use a replacement policy (static cache).
Nevertheless, a timeout can be given to specify the expiring time of cache values.
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 | |
|---|---|
PositiveListCache(java.util.Collection positiveList,
int timeToExpire)
Creates a new PositiveListCache and inits the positive key list. |
|
PositiveListCache(int timeToExpire)
Creates a new PositiveListCache. |
|
| Method Summary | |
|---|---|
void |
addToPositiveList(java.lang.Object key)
Adds a new allowed key to the positive list, if it is not
already present. |
void |
clear()
Empties the cache of all CacheObjects. |
CacheObject |
get(java.lang.Object key)
Gets the CacheObject associated with key from the
cache. |
java.lang.Object[] |
getPositiveList()
Returns the positive list currently used by this cache. |
void |
put(CacheObject obj)
For a CacheObject to be put into the cache, its key
CacheObject.getKey() has to be equal to one in the positive list of this
cache. |
void |
remove(java.lang.Object key)
Removes the CacheObject associated with key from the cache,
if found. |
void |
removeFromPositiveList(java.lang.Object key)
Removes the key from the positive list, if it is present. |
void |
setPositiveList(java.util.Collection positiveList)
Sets a new positive list for this cache. |
Cache.Statistic |
statistic()
Returns information collected by this cache since its creation. |
| Methods inherited from class tuwien.auto.calimero.buffer.cache.ExpiringCache |
|---|
notifyRemoved, removeExpired, startSweeper, stopSweeper |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PositiveListCache(java.util.Collection positiveList,
int timeToExpire)
PositiveListCache and inits the positive key list.
Optionally, an expiring time can be specified.
positiveList - a Collection holding the allowed keys for this cachetimeToExpire - timespan in seconds for cache objects to stay valid,
or 0 for no expiringpublic PositiveListCache(int timeToExpire)
PositiveListCache.
Optionally, an expiring time can be specified.
timeToExpire - timespan in seconds for cache objects to stay valid,
or 0 for no expiring| Method Detail |
|---|
public final void addToPositiveList(java.lang.Object key)
key to the positive list, if it is not
already present.
key - the new key objectpublic void clear()
CacheObjects.
This does not affect the positive list.
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 cachepublic final java.lang.Object[] getPositiveList()
public void put(CacheObject obj)
CacheObject to be put into the cache, its key
CacheObject.getKey() has to be equal to one in the positive list of this
cache.CacheObject is
renewed externally after it has been put into the cache, a new
put(CacheObject) is required for that object to apply the new 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 final void removeFromPositiveList(java.lang.Object key)
key from the positive list, if it is present.
The cache objects will be updated immediately according to the removed key.
key - key object to removepublic final void setPositiveList(java.util.Collection positiveList)
The old list is discarded. All cache objects will be updated immediately according to the new list.
positiveList - a Collection holding the allowed keys for this cachepublic Cache.Statistic statistic()
Cache
Cache.Statistic object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||