org.glassfish.hk2.utilities.cache.internal
Class LRUCacheImpl<K,V>

java.lang.Object
  extended by org.glassfish.hk2.utilities.cache.LRUCache<K,V>
      extended by org.glassfish.hk2.utilities.cache.internal.LRUCacheImpl<K,V>

public class LRUCacheImpl<K,V>
extends LRUCache<K,V>

The implementation of the LRUCache

Author:
jwells

Constructor Summary
LRUCacheImpl(int maxCacheSize)
           
 
Method Summary
 V get(K key)
          Returns the value associated with the given key.
 int getMaxCacheSize()
          Returns the maximum number of entries that will be stored in this cache
 CacheEntry put(K key, V value)
          Adds the given key and value pair into the cache
 void releaseCache()
          Clears all entries in the cache, for use when a known event makes the cache incorrect
 String toString()
           
 
Methods inherited from class org.glassfish.hk2.utilities.cache.LRUCache
createCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LRUCacheImpl

public LRUCacheImpl(int maxCacheSize)
Method Detail

get

public V get(K key)
Description copied from class: LRUCache
Returns the value associated with the given key. If there is no value, returns null

Specified by:
get in class LRUCache<K,V>
Parameters:
key - Must be a non-null key, appropriate for use as the key to a hash map
Returns:
The value associated with the key, or null if there is no such value

put

public CacheEntry put(K key,
                      V value)
Description copied from class: LRUCache
Adds the given key and value pair into the cache

Specified by:
put in class LRUCache<K,V>
Parameters:
key - Must be a non-null key, appropriate for use as the key to a hash map
value - Must be a non-null value
Returns:
A cache entry that can be used to remove this entry from the cache. Will not return null

releaseCache

public void releaseCache()
Description copied from class: LRUCache
Clears all entries in the cache, for use when a known event makes the cache incorrect

Specified by:
releaseCache in class LRUCache<K,V>

getMaxCacheSize

public int getMaxCacheSize()
Description copied from class: LRUCache
Returns the maximum number of entries that will be stored in this cache

Specified by:
getMaxCacheSize in class LRUCache<K,V>
Returns:
The maximum number of entries that will be stored in this cache

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012 Oracle Corporation. All Rights Reserved.