CaffeineCache
instead.public class LRUCache<K,V> extends SolrCacheBase implements SolrCache<K,V>, Accountable
Modifier and Type | Class and Description |
---|---|
static class |
LRUCache.CacheValue<V>
Deprecated.
|
SolrCacheBase.AutoWarmCountRef
SolrCache.State
SolrInfoBean.Category, SolrInfoBean.Group
autowarm, regenerator
CLEANUP_THREAD_PARAM, EVICTIONS_PARAM, HIT_RATIO_PARAM, HITS_PARAM, INITIAL_SIZE_PARAM, INSERTS_PARAM, LOOKUPS_PARAM, MAX_IDLE_TIME_PARAM, MAX_RAM_MB_PARAM, MAX_SIZE_PARAM, RAM_BYTES_USED_PARAM, SHOW_ITEMS_PARAM, SIZE_PARAM
NULL_ACCOUNTABLE
Constructor and Description |
---|
LRUCache()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Deprecated.
:TODO: copy from Map
|
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
|
Collection<Accountable> |
getChildResources()
Deprecated.
|
String |
getDescription()
Deprecated.
Simple one or two line description
|
long |
getMaxRamBytes()
Deprecated.
|
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. |
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.
|
V |
put(K key,
V value)
Deprecated.
:TODO: copy from Map
|
V |
putCacheValue(K key,
LRUCache.CacheValue<V> cacheValue)
Deprecated.
Visible for testing to create synthetic cache entries.
|
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 |
setSyntheticEntries(boolean syntheticEntries)
Deprecated.
Visible for testing.
|
int |
size()
Deprecated.
:TODO: copy from Map
|
String |
toString()
Deprecated.
|
void |
warm(SolrIndexSearcher searcher,
SolrCache<K,V> old)
Deprecated.
Warm this cache associated with
searcher using the old
cache object. |
calcHitRatio, getAutowarmDescription, getCategory, getState, getVersion, init, isAutowarmingOn, name, setState
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCategory, getMetricRegistry, getMetricsSnapshot, registerMetricName
getUniqueMetricTag, initializeMetrics
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 void setSyntheticEntries(boolean syntheticEntries)
public long getMaxRamBytes()
public int size()
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 put(K key, V value)
SolrCache
public V putCacheValue(K key, LRUCache.CacheValue<V> cacheValue)
public V get(K key)
SolrCache
public void clear()
SolrCache
public void warm(SolrIndexSearcher searcher, SolrCache<K,V> old)
SolrCache
searcher
using the old
cache object. this
and old
will have the same concrete type.public String getName()
SolrInfoBean
getName
in interface SolrInfoBean
public String getDescription()
SolrInfoBean
getDescription
in interface SolrInfoBean
public 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 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 long ramBytesUsed()
ramBytesUsed
in interface Accountable
public Collection<Accountable> getChildResources()
getChildResources
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.