public class LFUCache<K,V>
extends java.lang.Object
Constructor and Description |
---|
LFUCache(int cacheSize)
Creates a new LCU cache, suitable for use only within a single thread.
|
LFUCache(int cacheSize,
boolean concurrent)
Creates a new LCU cache, with the option of making it thread-safe
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the cache
|
boolean |
containsKey(K key)
Ask whether a given key is present in the cache.
The usage count of the entry is incremented if the entry exists. |
V |
get(K key)
Retrieves an entry from the cache.
The usage count of the entry is incremented. |
void |
put(K key,
V value)
Adds an entry to this cache.
|
int |
size()
Get the number of entries in the cache
|
public LFUCache(int cacheSize)
cacheSize
- the target number of entries to be kept in this cache.public LFUCache(int cacheSize, boolean concurrent)
cacheSize
- the maximum number of entries that will be kept in this cache.concurrent
- set to true if concurrent access is required, so that the
underlying map will be thread-safepublic V get(K key)
key
- the key whose associated value is to be returned.public boolean containsKey(K key)
key
- the key to be testedpublic void put(K key, V value)
key
- the key with which the specified value is to be associated.value
- a value to be associated with the specified key.public void clear()
public int size()
Copyright (c) 2004-2022 Saxonica Limited. All rights reserved.