Class MetaCache
- java.lang.Object
-
- org.apache.commons.jexl3.internal.MetaCache
-
final class MetaCache extends java.lang.ObjectA meta-cache that tracks multiple JexlCache instances via weak references.Each JexlCache created by this MetaCache is held via a WeakReference, allowing it to be garbage collected as soon as no strong references exist.
This allows for collective management of multiple caches, in particular clearing all caches at once. This operation is typically called when the uberspect class loader needs to change.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private intcleanUp()Cleans up all references whose referent (the cache) has been garbage collected.(package private) voidclearCaches()Clears all caches tracked by this MetaCache.(package private) <K,V>
JexlCache<K,V>createCache(int capacity)(package private) intsize()Gets the number of live caches currently tracked by this MetaCache.
-
-
-
Constructor Detail
-
MetaCache
MetaCache(java.util.function.IntFunction<JexlCache<?,?>> factory)
Constructs a MetaCache with the given cache factory.- Parameters:
factory- The factory function to create JexlCache instances given a capacity.
-
-
Method Detail
-
createCache
<K,V> JexlCache<K,V> createCache(int capacity)
-
clearCaches
void clearCaches()
Clears all caches tracked by this MetaCache.
-
cleanUp
private int cleanUp()
Cleans up all references whose referent (the cache) has been garbage collected.This method must be invoked while holding the lock on
references.- Returns:
- The remaining number of caches.
-
size
int size()
Gets the number of live caches currently tracked by this MetaCache.Any cache that is no longer strongly reference will get removed from the tracked set.
- Returns:
- The number of caches.
-
-