@PublicApi
public interface CacheFactory
This factory and its builders hide many of the implementation details of any cache. The only real control you have is whether it is a local (JVM-local) or shared cache. All of the following maybe be different in some execution environments, so you should not assume any of them in your code:
Cache,
CachedReference,
CacheManager| Modifier and Type | Method and Description |
|---|---|
<K,V> Cache<K,V> |
getCache(Class<?> owningClass,
String name)
Returns the cache with the given name, creates it if necessary.
|
<K,V> Cache<K,V> |
getCache(String name)
Returns the cache with the given name, creates it if necessary.
|
<K,V> Cache<K,V> |
getCache(String name,
CacheLoader<K,V> loader)
Returns the cache with the given name and loader, creates it if necessary.
|
<K,V> Cache<K,V> |
getCache(String name,
CacheLoader<K,V> loader,
CacheSettings required)
Returns the cache with the given name, loader and required cache settings, creates it if necessary.
|
<K,V> Cache<K,V> |
getCache(String name,
Class<K> keyType,
Class<V> valueType)
Deprecated.
since 2.0, use getCache(name) instead
|
<V> CachedReference<V> |
getCachedReference(Class<?> owningClass,
String name,
Supplier<V> supplier)
Returns a Cached Reference, creating it if necessary.
|
<V> CachedReference<V> |
getCachedReference(Class<?> owningClass,
String name,
Supplier<V> supplier,
CacheSettings required)
Returns a Cached Reference, creating it if necessary.
|
<V> CachedReference<V> |
getCachedReference(String name,
Supplier<V> supplier)
Returns a Cached Reference, creating it if necessary.
|
<V> CachedReference<V> |
getCachedReference(String name,
Supplier<V> supplier,
CacheSettings required)
Returns a Cached Reference, creating it if necessary.
|
@Nonnull <V> CachedReference<V> getCachedReference(@Nonnull String name, @Nonnull Supplier<V> supplier)
name - the name of the Cached Referencesupplier - the supplier for value to be cached, called if the value needs to be generated@Nonnull <V> CachedReference<V> getCachedReference(@Nonnull String name, @Nonnull Supplier<V> supplier, @Nonnull CacheSettings required)
name - the name of the Cached Referencesupplier - the supplier for value to be cached, called if the value needs to be generatedrequired - specifies the required cache settings@Nonnull <V> CachedReference<V> getCachedReference(@Nonnull Class<?> owningClass, @Nonnull String name, @Nonnull Supplier<V> supplier)
It is equivalent to calling getCachedReference(String, Supplier, CacheSettings)
owningClass - the owning classname - the name of the cache spaced within the owningClasssupplier - the supplier for value to be cached, called if the value needs to be generated@Nonnull <V> CachedReference<V> getCachedReference(@Nonnull Class<?> owningClass, @Nonnull String name, @Nonnull Supplier<V> supplier, @Nonnull CacheSettings required)
It is equivalent to calling getCachedReference(String, Supplier, CacheSettings)
owningClass - the owning classname - the name of the cache spaced within the owningClasssupplier - the supplier for value to be cached, called if the value needs to be generatedrequired - specifies the required cache settings@Nonnull <K,V> Cache<K,V> getCache(@Nonnull String name)
getCache(String, CacheLoader)
with name and null.name - the name of the cache@Nonnull <K,V> Cache<K,V> getCache(@Nonnull Class<?> owningClass, @Nonnull String name)
It is equivalent to calling getCache(String) with the computed name.
owningClass - the owning classname - the name of the cache spaced within the owningClass@Nonnull <K,V> Cache<K,V> getCache(@Nonnull String name, @Nullable CacheLoader<K,V> loader)
getCache(String, CacheLoader, CacheSettings)
with name, null and new CacheSettingsBuilder().build().name - the name of the cacheloader - the loader that will be used to provide values for keys that will be added to the cache. null indicates no loader@Nonnull <K,V> Cache<K,V> getCache(@Nonnull String name, @Nullable CacheLoader<K,V> loader, @Nonnull CacheSettings required)
name - the name of the cacheloader - the loader that will be used to provide values for keys that will be added to the cache. null indicates no loaderrequired - the cache settings that are required to be set if the cache is created.@Deprecated @Nonnull <K,V> Cache<K,V> getCache(@Nonnull String name, @Nonnull Class<K> keyType, @Nonnull Class<V> valueType)
Cache<String,String> firstCache = cacheManager.getCache("myCache", String.class, String.class);
Cache<String,Long> secondCache = cacheManager.getCache("myCache", String.class, Long.class);
the second call to getCache will result in a ClassCastException.
name - the name of the cachekeyType - the type of keys in the cache. Must extend SerializablevalueType - the type of values in the cache. Must extend SerializableCopyright © 2018 Atlassian. All rights reserved.