Package com.atlassian.jira.util.cache
Class CompositeKeyCache<R,S,T>
java.lang.Object
com.atlassian.jira.util.cache.CompositeKeyCache<R,S,T>
- Type Parameters:
R- the first key, usually a string. Must be a type that can be used as a map key (ie. immutable with correct equals/hashcode).S- the field name, usually a string. Must be a type that can be used as a map key (ie. immutable with correct equals/hashcode).T- the result thing.
Deprecated, for removal: This API element is subject to removal in a future version.
since 10.4
Cache of (R, S) -> T. Designed to be used for general mappings of things to a field in an index.
Usage:
CompositeKeyCache<IndexReader, String, Collection<String>[]> cache = CompositeKeyCache.createWeakFirstKeySoftValueCache();
cache.get(reader, fieldName,
new Supplier<Collection<String>[]>()
{
public Collection<String>[] get()
{
return doStuff(reader, fieldName);
}
}
);
-
Method Summary
Modifier and TypeMethodDescriptionstatic <R,S, T> CompositeKeyCache <R, S, T> Deprecated.@since v5.2 please supply a name so we can instrument this cache.static <R,S, T> CompositeKeyCache <R, S, T> createWeakFirstKeySoftValueCache(String cacheName) Deprecated, for removal: This API element is subject to removal in a future version.This cache caches the first (R) reference weakly, the second (S) reference strongly and the value (T) reference softly.Deprecated, for removal: This API element is subject to removal in a future version.Get the thing mapped to this key for the specified reader.
-
Method Details
-
createWeakFirstKeySoftValueCache
Deprecated, for removal: This API element is subject to removal in a future version.This cache caches the first (R) reference weakly, the second (S) reference strongly and the value (T) reference softly. This is specifically designed for use with Lucene where theIndexReaderis being recycled regularly (the R) and the terms (T) may be softly referenced.- Type Parameters:
R- the first key typeS- the second key typeT- the value type- Parameters:
cacheName- A Name to use when we instrument an instance of this cache. If null the cache will not be instrumented- Returns:
- a cache with weak references to the first key and soft references to the value.
-
createWeakFirstKeySoftValueCache
Deprecated.@since v5.2 please supply a name so we can instrument this cache.A useful way to build the cche for testing as instrumentation requires the ComponentAccessor to be initialised. -
get
Deprecated, for removal: This API element is subject to removal in a future version.Get the thing mapped to this key for the specified reader.- Parameters:
one- the first onetwo- the second onesupplier- to generate the value if not already there, only called if not already cached.- Returns:
- the cached value
-