Package jadex.commons.collection
Class Cache
- java.lang.Object
- 
- jadex.commons.collection.Cache
 
- 
 public class Cache extends java.lang.ObjectCache that provide expiration in case of a) timetolive is exceeded b) the max number of data has been reached (lru behaviour)
- 
- 
Field SummaryFields Modifier and Type Field Description static longDEFAULT_TIME_TO_LIVEThe default time to live time span (5 mins).protected LRUlruThe lru.protected longttlThe time to live.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanExpire(java.lang.Object key)Test if an entry can expire.booleancontainsKey(java.lang.Object key)Test if a key is contained.java.lang.Objectget(java.lang.Object key, long now)Get data from the cache.voidput(java.lang.Object key, java.lang.Object value, long now)Put an entry in the cache.voidput(java.lang.Object key, java.lang.Object value, long now, long ttl)Put an entry in the cache.booleanremove(java.lang.Object key)Remove an entry.intsize()Get the size.
 
- 
- 
- 
Field Detail- 
DEFAULT_TIME_TO_LIVEpublic static final long DEFAULT_TIME_TO_LIVE The default time to live time span (5 mins).- See Also:
- Constant Field Values
 
 - 
lruprotected LRU lru The lru.
 - 
ttlprotected long ttl The time to live.
 
- 
 - 
Constructor Detail- 
Cachepublic Cache(int max) Create a new cache.
 - 
Cachepublic Cache(int max, long ttl)Create a new cache.
 - 
Cachepublic Cache(LRU lru, long ttl) Create a new cache.
 
- 
 - 
Method Detail- 
putpublic void put(java.lang.Object key, java.lang.Object value, long now)Put an entry in the cache.- Parameters:
- key- The key.
- value- The value.
- now- The current time.
 
 - 
putpublic void put(java.lang.Object key, java.lang.Object value, long now, long ttl)Put an entry in the cache.- Parameters:
- key- The key.
- value- The value.
- now- The current time (-1 for never expire).
 
 - 
getpublic java.lang.Object get(java.lang.Object key, long now)Get data from the cache.- Parameters:
- key- The key.
- now- The current time (-1 for never expire).
- Returns:
- The cached object.
 
 - 
removepublic boolean remove(java.lang.Object key) Remove an entry.- Parameters:
- key- The key.
 
 - 
containsKeypublic boolean containsKey(java.lang.Object key) Test if a key is contained.- Parameters:
- key- The key.
- Returns:
- True if contained.
 
 - 
canExpirepublic boolean canExpire(java.lang.Object key) Test if an entry can expire.- Parameters:
- key- The key.
- Returns:
- True, if entry can expire.
 
 - 
sizepublic int size() Get the size.- Returns:
- The size.
 
 
- 
 
-