org.jgroups.util
Class ExpiryCache<K>

java.lang.Object
  extended by 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
 
Method Summary
 boolean addIfAbsentOrExpired(K key)
           
 void clear()
           
 boolean contains(K key)
           
 long getTimeout()
           
 boolean hasExpired(K key)
           
protected static boolean hasExpired(long val)
           
 void remove(K key)
           
 void removeAll(java.util.Collection<K> keys)
           
 int removeExpiredElements()
           
 void setTimeout(long timeout)
           
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

timeout

protected long timeout

map

protected final java.util.concurrent.ConcurrentMap<K,java.lang.Long> map
Constructor Detail

ExpiryCache

public ExpiryCache(long timeout)
Creates a new instance

Parameters:
timeout - Timeout in ms
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 class java.lang.Object

hasExpired

protected static boolean hasExpired(long val)


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.