CaffeineCache
instead.public class LFUCache<K,V> extends Object implements SolrCache<K,V>, Accountable
This implementation does not use a separate cleanup thread. Instead it uses the calling thread itself to do the cleanup when the size of the cache exceeds certain limits.
Also see SolrCaching
This API is experimental and subject to change
ConcurrentLFUCache
,
SolrCache
SolrCache.State
SolrInfoBean.Category, SolrInfoBean.Group
Modifier and Type | Field and Description |
---|---|
static String |
ACCEPTABLE_SIZE_PARAM
Deprecated.
|
static String |
AUTOWARM_COUNT_PARAM
Deprecated.
|
static String |
CLEANUP_THREAD_PARAM
Deprecated.
|
static String |
INITIAL_SIZE_PARAM
Deprecated.
|
static String |
MIN_SIZE_PARAM
Deprecated.
|
static String |
SHOW_ITEMS_PARAM
Deprecated.
|
static String |
TIME_DECAY_PARAM
Deprecated.
|
EVICTIONS_PARAM, HIT_RATIO_PARAM, HITS_PARAM, INSERTS_PARAM, LOOKUPS_PARAM, MAX_IDLE_TIME_PARAM, MAX_RAM_MB_PARAM, MAX_SIZE_PARAM, RAM_BYTES_USED_PARAM, SIZE_PARAM
NULL_ACCOUNTABLE
Constructor and Description |
---|
LFUCache()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Deprecated.
:TODO: copy from Map
|
void |
close()
Deprecated.
Frees any non-memory resources
|
V |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction)
Deprecated.
Get an existing element or atomically compute it if missing.
|
V |
get(K key)
Deprecated.
:TODO: copy from Map
|
SolrInfoBean.Category |
getCategory()
Deprecated.
Category of this component
|
String |
getDescription()
Deprecated.
Simple one or two line description
|
int |
getMaxRamMB()
Deprecated.
Returns maximum size limit (in MB) if set and supported, -1 otherwise.
|
int |
getMaxSize()
Deprecated.
Returns maximum size limit (number of items) if set and supported, -1 otherwise.
|
Set<String> |
getMetricNames()
Deprecated.
Modifiable set of metric names that this component reports (default is null,
which means none).
|
String |
getName()
Deprecated.
Simple common usage name, e.g.
|
SolrMetricsContext |
getSolrMetricsContext()
Deprecated.
Implementing classes should override this method to provide the context obtained in
SolrMetricProducer.initializeMetrics(SolrMetricsContext, String) to ensure proper cleanup of metrics
at the end of the life-cycle of this component. |
SolrCache.State |
getState()
Deprecated.
Returns the last State set on this instance
|
Object |
init(Map args,
Object persistence,
CacheRegenerator regenerator)
Deprecated.
The initialization routine.
|
void |
initializeMetrics(SolrMetricsContext parentContext,
String scope)
Deprecated.
Initialize metrics specific to this producer.
|
String |
name()
Deprecated.
Name the Cache can be referenced with by SolrRequestHandlers.
|
V |
put(K key,
V value)
Deprecated.
:TODO: copy from Map
|
long |
ramBytesUsed()
Deprecated.
|
V |
remove(K key)
Deprecated.
|
void |
setMaxRamMB(int maxRamMB)
Deprecated.
Set maximum size limit (in MB), or -1 for unlimited.
|
void |
setMaxSize(int maxSize)
Deprecated.
Set maximum size limit (number of items), or -1 for unlimited.
|
void |
setState(SolrCache.State state)
Deprecated.
Set different cache states.
|
int |
size()
Deprecated.
:TODO: copy from Map
|
String |
toString()
Deprecated.
|
void |
warm(SolrIndexSearcher searcher,
SolrCache old)
Deprecated.
Warm this cache associated with
searcher using the old
cache object. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getMetricRegistry, getMetricsSnapshot, registerMetricName
getUniqueMetricTag, initializeMetrics
getChildResources
public static final String TIME_DECAY_PARAM
public static final String CLEANUP_THREAD_PARAM
public static final String INITIAL_SIZE_PARAM
public static final String MIN_SIZE_PARAM
public static final String ACCEPTABLE_SIZE_PARAM
public static final String AUTOWARM_COUNT_PARAM
public static final String SHOW_ITEMS_PARAM
public Object init(Map args, Object persistence, CacheRegenerator regenerator)
SolrCache
args
map.
The persistence object will exist across different lifetimes of similar caches. For example, all filter caches will share the same persistence object, sometimes at the same time (it must be thread-safe). If null is passed, then the cache implementation should create and return a new persistence object. If not null, the passed in object should be returned again.
Since it will exist across the lifetime of many caches, care should be taken to not reference any particular cache instance and prevent it from being garbage collected (no using inner classes unless they are static).
The persistence object is designed to be used as a way for statistics to accumulate across all instances of the same type of cache, however the object may be of any type desired by the cache implementation.
The CacheRegenerator
is what the cache uses during auto-warming to
regenerate an item in the new cache from an entry in the old cache.
public String name()
SolrCache
public int size()
SolrCache
public V put(K key, V value)
SolrCache
public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
SolrCache
computeIfAbsent
in interface SolrCache<K,V>
key
- keymappingFunction
- function to compute the element. If the function returns a null
result the cache mapping will not be created. NOTE: this function
must NOT attempt to modify any mappings in the cache.public V get(K key)
SolrCache
public void clear()
SolrCache
public void setState(SolrCache.State state)
SolrCache
public SolrCache.State getState()
SolrCache
getState
in interface SolrCache<K,V>
SolrCache.setState(org.apache.solr.search.SolrCache.State)
public void warm(SolrIndexSearcher searcher, SolrCache old)
SolrCache
searcher
using the old
cache object. this
and old
will have the same concrete type.public void close() throws IOException
SolrCache
close
in interface AutoCloseable
close
in interface SolrMetricProducer
close
in interface SolrCache<K,V>
IOException
public String getName()
SolrInfoBean
getName
in interface SolrInfoBean
public String getDescription()
SolrInfoBean
getDescription
in interface SolrInfoBean
public SolrInfoBean.Category getCategory()
SolrInfoBean
getCategory
in interface SolrInfoBean
public SolrMetricsContext getSolrMetricsContext()
SolrMetricProducer
SolrMetricProducer.initializeMetrics(SolrMetricsContext, String)
to ensure proper cleanup of metrics
at the end of the life-cycle of this component.getSolrMetricsContext
in interface SolrMetricProducer
public void initializeMetrics(SolrMetricsContext parentContext, String scope)
SolrMetricProducer
initializeMetrics
in interface SolrMetricProducer
parentContext
- parent metrics context. If this component has the same life-cycle as the parent
it can simply use the parent context, otherwise it should obtain a child context
using SolrMetricsContext.getChildContext(Object)
passing this
as the child.scope
- component scopepublic Set<String> getMetricNames()
SolrInfoBean
SolrInfoBean.registerMetricName(String)
to capture what metrics names are reported from this component.
NOTE: this set has to allow iteration under modifications.
getMetricNames
in interface SolrInfoBean
public long ramBytesUsed()
ramBytesUsed
in interface Accountable
public int getMaxSize()
SolrCache
getMaxSize
in interface SolrCache<K,V>
public void setMaxSize(int maxSize)
SolrCache
setMaxSize
in interface SolrCache<K,V>
public int getMaxRamMB()
SolrCache
getMaxRamMB
in interface SolrCache<K,V>
public void setMaxRamMB(int maxRamMB)
SolrCache
setMaxRamMB
in interface SolrCache<K,V>
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.