|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.jira.util.cache.CompositeKeyCache<R,S,T>
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.public class CompositeKeyCache<R,S,T>
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 | ||
|---|---|---|
static
|
createWeakFirstKeySoftValueCache()
This cache caches the first (R) reference weakly, the second (S) reference strongly and the value (T) reference softly. |
|
T |
get(R one,
S two,
Supplier<T> supplier)
Get the thing mapped to this key for the specified reader. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <R,S,T> CompositeKeyCache<R,S,T> createWeakFirstKeySoftValueCache()
IndexReader is being recycled regularly (the R) and the terms (T) may be softly referenced.
R - the first key typeS - the second key typeT - the value type
public T get(@NotNull
R one,
@NotNull
S two,
Supplier<T> supplier)
one - the first onetwo - the second onesupplier - to generate the value if not already there, only called if not already cached.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||