|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.cache.impl.AbstractCacheManager
public abstract class AbstractCacheManager
A partial implementation of CacheManager.
| Field Summary | |
|---|---|
protected com.atlassian.util.concurrent.Function<String,com.atlassian.util.concurrent.ManagedLock> |
cacheCreationLocks
Used to synchronize the creation of caches. |
protected ConcurrentMap<String,com.atlassian.util.concurrent.Supplier<ManagedCache>> |
caches
Map of all the caches. |
protected CacheSettingsDefaultsProvider |
cacheSettingsDefaultsProvider
|
| Constructor Summary | |
|---|---|
protected |
AbstractCacheManager(CacheSettingsDefaultsProvider cacheSettingsDefaultsProvider)
|
| Method Summary | ||
|---|---|---|
protected abstract
|
createComputingCache(String name,
CacheSettings settings,
CacheLoader<K,V> loader)
Creates a cache that upon a miss is able to populate itself using the loader. |
|
protected abstract ManagedCache |
createSimpleCache(String name,
CacheSettings settings)
Creates a cache with no loader, i.e. |
|
void |
flushCaches()
Flush the contents of all flushable caches registered with the cache manager. |
|
|
getCache(Class<?> owningClass,
String name)
Returns the cache with the given name, creates it if necessary. |
|
|
getCache(String name)
Returns the cache with the given name, creates it if necessary. |
|
|
getCache(String name,
CacheLoader<K,V> loader)
Returns the cache with the given name and loader, creates it if necessary. |
|
|
getCache(String name,
CacheLoader<K,V> loader,
CacheSettings settings)
Returns the cache with the given name, loader and required cache settings, creates it if necessary. |
|
|
getCache(String name,
Class<K> keyType,
Class<V> valueType)
Returns a cache with the given name, and the types specified. |
|
|
getCachedReference(Class<?> owningClass,
String name,
Supplier<V> supplier)
Returns a Cached Reference, creating it if necessary. |
|
|
getCachedReference(Class<?> owningClass,
String name,
Supplier<V> supplier,
CacheSettings settings)
Returns a Cached Reference, creating it if necessary. |
|
|
getCachedReference(String name,
Supplier<V> supplier)
Returns a Cached Reference, creating it if necessary. |
|
Collection<Cache<?,?>> |
getCaches()
Gets the collection of caches managed. |
|
ManagedCache |
getManagedCache(String name)
Returns the managed cache for the specified name. |
|
Collection<ManagedCache> |
getManagedCaches()
Gets the collection of caches managed. |
|
protected CacheSettings |
mergeSettings(String name,
CacheSettings settings)
|
|
void |
shutdown()
Shuts down and clean all data of the current instance and its all caches. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.atlassian.cache.CacheFactory |
|---|
getCachedReference |
| Field Detail |
|---|
protected final ConcurrentMap<String,com.atlassian.util.concurrent.Supplier<ManagedCache>> caches
cacheCreationLocks
to ensure that a cache is created only once.
protected final com.atlassian.util.concurrent.Function<String,com.atlassian.util.concurrent.ManagedLock> cacheCreationLocks
protected final CacheSettingsDefaultsProvider cacheSettingsDefaultsProvider
| Constructor Detail |
|---|
protected AbstractCacheManager(CacheSettingsDefaultsProvider cacheSettingsDefaultsProvider)
| Method Detail |
|---|
@Nonnull public Collection<Cache<?,?>> getCaches()
CacheManager
getCaches in interface CacheManagerCaches. The returned collection will only include caches created via
the getCache(...) methods. Caches created via the getCachedReference(...)
methods are not included.@Nonnull public Collection<ManagedCache> getManagedCaches()
CacheManagergetCache(...) and
getCachedReference(...) methods.
getManagedCaches in interface CacheManagerManagedCaches.
@Nullable
public ManagedCache getManagedCache(@Nonnull
String name)
CacheManager
getManagedCache in interface CacheManagername - the name of the managed cache to retrieve
ManagedCache specified by name
or null if no cache exists.public void flushCaches()
CacheManager
flushCaches in interface CacheManagerCacheSettings.getFlushable()
@Nonnull
public <K,V> Cache<K,V> getCache(@Nonnull
String name)
CacheFactoryCacheFactory.getCache(String, CacheLoader)
with name and null.
getCache in interface CacheFactoryname - the name of the cache
@Nonnull
public <K,V> Cache<K,V> getCache(@Nonnull
Class<?> owningClass,
@Nonnull
String name)
CacheFactory
It is equivalent to calling CacheFactory.getCache(String) with the computed name.
getCache in interface CacheFactoryowningClass - the owning classname - the name of the cache spaced within the owningClass
@Nonnull
public <K,V> Cache<K,V> getCache(@Nonnull
String name,
@Nonnull
Class<K> keyType,
@Nonnull
Class<V> valueType)
CacheFactory
getCache in interface CacheFactoryname - the name of the cachekeyType - the type of keys in the cache. Must extend SerializablevalueType - the type of values in the cache. Must extend Serializable
@Nonnull
public <K,V> Cache<K,V> getCache(@Nonnull
String name,
CacheLoader<K,V> loader)
CacheFactoryCacheFactory.getCache(String, CacheLoader, CacheSettings)
with name, null and new CacheSettingsBuilder().build().
getCache in interface CacheFactoryname - 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
public <V> CachedReference<V> getCachedReference(@Nonnull
String name,
@Nonnull
Supplier<V> supplier)
CacheFactory
getCachedReference in interface CacheFactoryname - the name of the Cached Referencesupplier - the supplier for value to be cached, called if the value needs to be generated
@Nonnull
public <V> CachedReference<V> getCachedReference(@Nonnull
Class<?> owningClass,
@Nonnull
String name,
@Nonnull
Supplier<V> supplier)
CacheFactory
It is equivalent to calling CacheFactory.getCachedReference(String, Supplier, CacheSettings)
getCachedReference in interface CacheFactoryowningClass - 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
public <V> CachedReference<V> getCachedReference(@Nonnull
Class<?> owningClass,
@Nonnull
String name,
@Nonnull
Supplier<V> supplier,
@Nonnull
CacheSettings settings)
CacheFactory
It is equivalent to calling CacheFactory.getCachedReference(String, Supplier, CacheSettings)
getCachedReference in interface CacheFactoryowningClass - 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 generatedsettings - specifies the required cache settings
@Nonnull
public <K,V> Cache<K,V> getCache(@Nonnull
String name,
CacheLoader<K,V> loader,
@Nonnull
CacheSettings settings)
CacheFactory
getCache in interface CacheFactoryname - 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 loadersettings - the cache settings that are required to be set if the cache is created.
protected abstract <K,V> ManagedCache createComputingCache(@Nonnull
String name,
@Nonnull
CacheSettings settings,
CacheLoader<K,V> loader)
protected abstract ManagedCache createSimpleCache(@Nonnull
String name,
@Nonnull
CacheSettings settings)
name - the name to give the cache (required)
protected CacheSettings mergeSettings(String name,
CacheSettings settings)
public void shutdown()
CacheManager
shutdown in interface CacheManager
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||