Package org.jgroups.util
Class ExpiryCache<K>
- java.lang.Object
-
- org.jgroups.util.ExpiryCache<K>
-
public class ExpiryCache<K> extends java.lang.Object
Cache which maintains timestamps for keys, and methods to remove/replace expired keys. Compared toAgeOutCache
, ExpiryCache doesn't require a timer task to run- Version:
- 3.3
- Author:
- Bela Ban
-
-
Constructor Summary
Constructors Constructor Description ExpiryCache(long timeout)
Creates a new instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addIfAbsentOrExpired(K key)
void
clear()
boolean
contains(K key)
long
getTimeout()
protected boolean
hasExpired(long val, long current_time)
boolean
hasExpired(K key)
void
remove(K key)
void
removeAll(java.util.Collection<K> keys)
int
removeExpiredElements()
void
setTimeout(long timeout)
int
size()
java.lang.String
toString()
-
-
-
Field Detail
-
timeout
protected long timeout
-
map
protected final java.util.concurrent.ConcurrentMap<K,java.lang.Long> map
-
-
Method Detail
-
getTimeout
public long getTimeout()
-
setTimeout
public void setTimeout(long timeout)
-
addIfAbsentOrExpired
public boolean addIfAbsentOrExpired(K key)
-
contains
public boolean contains(K key)
-
hasExpired
public boolean hasExpired(K key)
-
remove
public void remove(K key)
-
removeAll
public void removeAll(java.util.Collection<K> keys)
-
removeExpiredElements
public int removeExpiredElements()
-
clear
public void clear()
-
size
public int size()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hasExpired
protected boolean hasExpired(long val, long current_time)
-
-