E- the type of element that this cache holds.
public final class IntLruCache<E> extends java.lang.Object implements java.lang.AutoCloseable, java.io.Serializable
When an element is evicted it is closed by calling the closer function with the element as an argument.
When a new key arrives the factory function is called in order to create the new element associated with that key.
|Constructor and Description|
|Modifier and Type||Method and Description|
Looks up an element in the cache, creating a new element if it doesn't exist and evicting the least recently used element if there's no space left in the cache.
public IntLruCache(int capacity, java.util.function.IntFunction<E> factory, java.util.function.Consumer<E> closer)
capacity- this is the fixed capacity of the cache.
factory- a function for constructing new elements based upon keys.
closer- a function for cleaning up resources associated with elements.
public E lookup(int key)
key- the key to lookup the element by.
public int capacity()
public void close()
Copyright © 2014-2017 Real Logic Ltd. All Rights Reserved.