Package org.jgroups.blocks
Class LazyRemovalCache<K,V>
- java.lang.Object
- 
- org.jgroups.blocks.LazyRemovalCache<K,V>
 
- 
 public class LazyRemovalCache<K,V> extends java.lang.ObjectCache which doesn't remove elements on remove(), removeAll() or retainAll(), but only removes elements when a configurable size limit has been exceeded. In that case, all elements marked as removable and older than a configurable time are evicted. Elements are marked as removable by remove(), removeAll() and retainAll(). When an elements is marked as removable, but later reinserted, the mark is removed.- Author:
- Bela Ban
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classLazyRemovalCache.Entry<V>static interfaceLazyRemovalCache.Printable<K,V>
 - 
Constructor SummaryConstructors Constructor Description LazyRemovalCache()LazyRemovalCache(int max_elements, long max_age)Creates a new instance
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(K key, V val)protected booleanadd(K key, V val, boolean if_absent)voidaddAll(java.util.Map<K,V> m)protected voidaddAll(java.util.Map<K,V> m, boolean if_absent)voidaddAllIfAbsent(java.util.Map<K,V> m)booleanaddIfAbsent(K key, V val)voidclear(boolean force)booleancontainsKey(K key)booleancontainsKeys(java.util.Collection<K> keys)Returns true if all of the keys in keys are present.java.util.Map<K,V>contents()java.util.Map<K,V>contents(boolean skip_removed_values)java.util.Set<java.util.Map.Entry<K,LazyRemovalCache.Entry<V>>>entrySet()Vget(K key)KgetByValue(V val)java.util.Set<K>keySet()java.util.Set<V>nonRemovedValues()Adds all value which have not been marked as removable to the returned setjava.lang.StringprintCache()java.lang.StringprintCache(LazyRemovalCache.Printable print_function)voidremove(K key)voidremove(K key, boolean force)voidremoveAll(java.util.Collection<K> keys)voidremoveAll(java.util.Collection<K> keys, boolean force)voidremoveMarkedElements()Removes elements marked as removablevoidremoveMarkedElements(boolean force)Removes elements marked as removablevoidretainAll(java.util.Collection<K> keys)voidretainAll(java.util.Collection<K> keys, boolean force)intsize()java.lang.StringtoString()java.util.Set<V>values()java.lang.Iterable<LazyRemovalCache.Entry<V>>valuesIterator()
 
- 
- 
- 
Constructor Detail- 
LazyRemovalCachepublic LazyRemovalCache() 
 - 
LazyRemovalCachepublic LazyRemovalCache(int max_elements, long max_age)Creates a new instance- Parameters:
- max_elements- The max number of elements in the cache
- max_age- The max age (in ms) an entry can have before it is considered expired (and can be removed on the next sweep)
 
 
- 
 - 
Method Detail- 
entrySetpublic java.util.Set<java.util.Map.Entry<K,LazyRemovalCache.Entry<V>>> entrySet() 
 - 
containsKeypublic boolean containsKey(K key) 
 - 
containsKeyspublic boolean containsKeys(java.util.Collection<K> keys) Returns true if all of the keys in keys are present. Returns false if one or more of the keys are absent
 - 
removepublic void remove(K key) 
 - 
removepublic void remove(K key, boolean force) 
 - 
removeAllpublic void removeAll(java.util.Collection<K> keys) 
 - 
removeAllpublic void removeAll(java.util.Collection<K> keys, boolean force) 
 - 
clearpublic void clear(boolean force) 
 - 
retainAllpublic void retainAll(java.util.Collection<K> keys) 
 - 
retainAllpublic void retainAll(java.util.Collection<K> keys, boolean force) 
 - 
keySetpublic java.util.Set<K> keySet() 
 - 
valuespublic java.util.Set<V> values() 
 - 
valuesIteratorpublic java.lang.Iterable<LazyRemovalCache.Entry<V>> valuesIterator() 
 - 
nonRemovedValuespublic java.util.Set<V> nonRemovedValues() Adds all value which have not been marked as removable to the returned set- Returns:
 
 - 
sizepublic int size() 
 - 
printCachepublic java.lang.String printCache() 
 - 
printCachepublic java.lang.String printCache(LazyRemovalCache.Printable print_function) 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
removeMarkedElementspublic void removeMarkedElements(boolean force) Removes elements marked as removable- Parameters:
- force- If set to true, all elements marked as 'removable' will get removed, regardless of expiration
 
 - 
removeMarkedElementspublic void removeMarkedElements() Removes elements marked as removable
 
- 
 
-