Top Description Fields Constructors Methods
com.sun.faces.util

public Class LRUCache<K, V>

extends Object
Class Inheritance
Imports
java.util.Objects, java.util.concurrent.locks.ReentrantLock

LRU Cache adapted to the code style of Faces
Author
Paolo Bernardi

Field Summary

Modifier and TypeField and Description
private final LRUMap<K, V>
private final Cache.Factory<K, V>
private final ReentrantLock

Constructor Summary

AccessConstructor and Description
public
LRUCache(Cache.Factory<K, V> factory, int capacity)

Method Summary

Modifier and TypeMethod and Description
public void
clear()

clear the cache

public V

Returns:

the value from cache if exists, otherwise the newly created and saved value
get
(K
the key
key
)

get from cache if exists else init the value + save in cache + return created value

public V
remove(final K key)

remove an element identified by the passed key from the cache

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final LRUMap<K, V> cache
factoryback to summary
private final Cache.Factory<K, V> factory
lockback to summary
private final ReentrantLock lock

Constructor Detail

LRUCacheback to summary
public LRUCache(Cache.Factory<K, V> factory, int capacity)

Method Detail

clearback to summary
public void clear()

clear the cache

getback to summary
public V get(K key)

get from cache if exists else init the value + save in cache + return created value

Parameters
key:K

the key

Returns:V

the value from cache if exists, otherwise the newly created and saved value

removeback to summary
public V remove(final K key)

remove an element identified by the passed key from the cache