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 to AgeOutCache
,
ExpiryCache doesn't require a timer task to run
- Version:
- 3.3
- Author:
- Bela Ban
Field Summary |
protected java.util.concurrent.ConcurrentMap<K,java.lang.Long> |
map
|
protected long |
timeout
|
Constructor Summary |
ExpiryCache(long timeout)
Creates a new instance |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
timeout
protected long timeout
map
protected final java.util.concurrent.ConcurrentMap<K,java.lang.Long> map
ExpiryCache
public ExpiryCache(long timeout)
- Creates a new instance
- Parameters:
timeout
- Timeout in ms
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 class java.lang.Object
hasExpired
protected static boolean hasExpired(long val)
Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.