net.floodlightcontroller.util
Class TimedCache<K>
java.lang.Object
net.floodlightcontroller.util.TimedCache<K>
- Type Parameters:
K
- Type of the values in this cache
public class TimedCache<K>
- extends java.lang.Object
The key is any object/hash-code
The value is time-stamp in milliseconds
The time interval denotes the interval for which the entry should remain in the hashmap.
If an entry is present in the Linkedhashmap, it does not mean that it's valid (recently seen)
Constructor Summary |
TimedCache(int capacity,
int timeToLive)
|
Method Summary |
long |
getTimeoutInterval()
|
boolean |
update(K key)
Always try to update the cache and set the last-seen value for this key. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TimedCache
public TimedCache(int capacity,
int timeToLive)
- Parameters:
capacity
- the maximum number of entries in the cache before the
oldest entry is evicted.timeToLive
- specified in milliseconds
getTimeoutInterval
public long getTimeoutInterval()
update
public boolean update(K key)
- Always try to update the cache and set the last-seen value for this key.
Return true, if a valid existing field was updated, else return false.
(note: if multiple threads update simultaneously, one of them will succeed,
other wills return false)
- Parameters:
key
-
- Returns:
- boolean