CaffeineCache
instead.public class FastLRUCache<K,V> extends SolrCacheBase 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
ConcurrentLRUCache
,
SolrCache
SolrCacheBase.AutoWarmCountRef
SolrCache.State
SolrInfoBean.Category, SolrInfoBean.Group
Modifier and Type | Field and Description |
---|---|
static String |
ACCEPTABLE_SIZE_PARAM
Deprecated.
|
static String |
MIN_SIZE_PARAM
Deprecated.
|
autowarm, regenerator
ASYNC_PARAM, 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 |
---|
FastLRUCache()
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,
IOFunction<? super K,? extends V> mappingFunction)
Deprecated.
Get an existing element or atomically compute it if missing.
|
protected String |
generateDescription()
Deprecated.
|
protected String |
generateDescription(int limit,
int initialSize,
int minLimit,
int acceptableLimit,
boolean newThread)
Deprecated.
|
protected String |
generateDescription(long maxRamBytes,
long ramLowerWatermark,
boolean newThread)
Deprecated.
|
V |
get(K key)
Deprecated.
:TODO: copy from Map
|
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. |
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
|
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. |
calcHitRatio, getAutowarmDescription, getCategory, getState, getVersion, init, isAutowarmingOn, name
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCategory, getMetricRegistry, getMetricsSnapshot, registerMetricName
getUniqueMetricTag, initializeMetrics
getChildResources
public static final String MIN_SIZE_PARAM
public static final String ACCEPTABLE_SIZE_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.
protected String generateDescription()
protected String generateDescription(int limit, int initialSize, int minLimit, int acceptableLimit, boolean newThread)
protected String generateDescription(long maxRamBytes, long ramLowerWatermark, boolean newThread)
public int size()
SolrCache
public V put(K key, V value)
SolrCache
public V get(K key)
SolrCache
public V computeIfAbsent(K key, IOFunction<? 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 void clear()
SolrCache
public void setState(SolrCache.State state)
SolrCache
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 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 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.