Top Methods
org.glassfish.hk2.utilities.general

public Interface WeakHashLRU<K>

Known Direct Implementers
org.glassfish.hk2.utilities.general.internal.WeakHashLRUImpl
Imports
org.glassfish.hk2.utilities.cache.CacheKeyFilter

Author
jwells

Method Summary

Modifier and TypeMethod and Description
public void
add(K
Must not be null
key
)

Adds the given key to the LRU.

public void
clear()

Removes all entries from this LRU

public void
clearStaleReferences()

Causes stale references to be cleared from the data structures.

public boolean

Returns:

true if found, false otherwise
contains
(K
The key to search for, may not be null
key
)

Tells if the given key is in the LRU

public void
releaseMatching(CacheKeyFilter<K>
A non-null filter that can be used to delete every key that matches the filter
filter
)

Releases all keys that match the filter

public boolean

Returns:

true if removed, false otherwise
remove
(K
The key to remove, may not be null
key
)

Removes the given key from the LRU, if found

public K

Returns:

The key that was removed, or null if the list is empty
remove
()

Removes the key that was Least Recently Used

public int

Returns:

The number of entries currently in the LRU
size
()

Returns the number of elements currently in the clock.

Method Detail

addback to summary
public void add(K key)

Adds the given key to the LRU. It will be placed at the MRU of the LRU. If this key already exists in the LRU it will be moved to the MRU

Parameters
key:K

Must not be null

clearback to summary
public void clear()

Removes all entries from this LRU

clearStaleReferencesback to summary
public void clearStaleReferences()

Causes stale references to be cleared from the data structures. Since this is a weak clock the references can go away at any time, which happens whenever any operation has been performed. However, it may be the case that no operation will be performed for a while and so this method is provided to have a no-op operation to call in order to clear out any stale references

containsback to summary
public boolean contains(K key)

Tells if the given key is in the LRU

Parameters
key:K

The key to search for, may not be null

Returns:boolean

true if found, false otherwise

releaseMatchingback to summary
public void releaseMatching(CacheKeyFilter<K> filter)

Releases all keys that match the filter

Parameters
filter:CacheKeyFilter<K>

A non-null filter that can be used to delete every key that matches the filter

removeback to summary
public boolean remove(K key)

Removes the given key from the LRU, if found

Parameters
key:K

The key to remove, may not be null

Returns:boolean

true if removed, false otherwise

removeback to summary
public K remove()

Removes the key that was Least Recently Used

Returns:K

The key that was removed, or null if the list is empty

sizeback to summary
public int size()

Returns the number of elements currently in the clock. References that have gone away because they were weakly referenced will not be counted in the size

Returns:int

The number of entries currently in the LRU