Class CacheManagerTemplate

java.lang.Object
com.atlassian.cache.impl.AbstractCacheManager
com.atlassian.confluence.impl.cache.CacheManagerTemplate
All Implemented Interfaces:
com.atlassian.cache.CacheFactory, com.atlassian.cache.CacheManager, CacheConfigManager

public abstract class CacheManagerTemplate extends com.atlassian.cache.impl.AbstractCacheManager implements CacheConfigManager
A partial implementation of CacheManager, which tries to smooth over the implementation horror show that is AbstractCacheManager, by taking care of the lifecycle concerns of weakly-referenced ManagedCache instances.
Since:
10.1
  • Field Summary

    Fields inherited from class com.atlassian.cache.impl.AbstractCacheManager

    cacheCreationLocks, caches, cacheSettingsDefaultsProvider
  • Constructor Summary

    Constructors
    Constructor
    Description
    CacheManagerTemplate(com.atlassian.cache.CacheSettingsDefaultsProvider cacheSettingsDefaultsProvider, com.atlassian.cache.impl.metrics.CacheManagerMetricEmitter cacheManagerMetricEmitter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    changeMaxCacheSize(String cacheName, int newMaxCacheSize)
    Changes the max cache size.
    protected abstract <V> ConfluenceCachedReference<V>
    createCachedReferenceInternal(String name, com.atlassian.cache.Supplier<V> supplier, com.atlassian.cache.CacheSettings settings)
     
    protected abstract <K, V> ConfluenceCache<K,V>
    createCacheInternal(String name, com.atlassian.cache.CacheSettings settings, @Nullable com.atlassian.cache.CacheLoader<K,V> loader)
     
    protected final <K, V> com.atlassian.cache.ManagedCache
    createComputingCache(String name, com.atlassian.cache.CacheSettings settings, com.atlassian.cache.CacheLoader<K,V> loader)
     
    protected final com.atlassian.cache.ManagedCache
    createSimpleCache(String name, com.atlassian.cache.CacheSettings settings)
     
    final <V> com.atlassian.cache.CachedReference<V>
    getCachedReference(String name, com.atlassian.cache.Supplier<V> supplier, com.atlassian.cache.CacheSettings settings)
     
    final com.atlassian.cache.ManagedCache
     
    final Collection<com.atlassian.cache.ManagedCache>
     
    protected final <K, V> com.atlassian.cache.ManagedCache
    getOrCreateCache(String name, com.atlassian.cache.Supplier<ConfluenceCache<K,V>> factory)
     
    protected final <V> com.atlassian.cache.ManagedCache
    getOrCreateCachedReference(String name, com.atlassian.cache.Supplier<ConfluenceCachedReference<V>> factory)
     

    Methods inherited from class com.atlassian.cache.impl.AbstractCacheManager

    flushCaches, getCache, getCache, getCache, getCache, getCache, getCachedReference, getCachedReference, getCachedReference, getCaches, mergeSettings, shutdown

    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

    getReadThroughCache, getReadThroughCache
  • Constructor Details

    • CacheManagerTemplate

      public CacheManagerTemplate(com.atlassian.cache.CacheSettingsDefaultsProvider cacheSettingsDefaultsProvider, com.atlassian.cache.impl.metrics.CacheManagerMetricEmitter cacheManagerMetricEmitter)
  • Method Details

    • createSimpleCache

      protected final com.atlassian.cache.ManagedCache createSimpleCache(String name, com.atlassian.cache.CacheSettings settings)
      Specified by:
      createSimpleCache in class com.atlassian.cache.impl.AbstractCacheManager
    • createComputingCache

      protected final <K, V> com.atlassian.cache.ManagedCache createComputingCache(String name, com.atlassian.cache.CacheSettings settings, com.atlassian.cache.CacheLoader<K,V> loader)
      Specified by:
      createComputingCache in class com.atlassian.cache.impl.AbstractCacheManager
    • getCachedReference

      public final <V> com.atlassian.cache.CachedReference<V> getCachedReference(String name, com.atlassian.cache.Supplier<V> supplier, com.atlassian.cache.CacheSettings settings)
      Specified by:
      getCachedReference in interface com.atlassian.cache.CacheFactory
    • createCacheInternal

      protected abstract <K, V> ConfluenceCache<K,V> createCacheInternal(String name, com.atlassian.cache.CacheSettings settings, @Nullable com.atlassian.cache.CacheLoader<K,V> loader)
    • createCachedReferenceInternal

      protected abstract <V> ConfluenceCachedReference<V> createCachedReferenceInternal(String name, com.atlassian.cache.Supplier<V> supplier, com.atlassian.cache.CacheSettings settings)
    • changeMaxCacheSize

      public final void changeMaxCacheSize(String cacheName, int newMaxCacheSize)
      Description copied from interface: CacheConfigManager
      Changes the max cache size.
      Specified by:
      changeMaxCacheSize in interface CacheConfigManager
      Parameters:
      cacheName - cache name
      newMaxCacheSize - new max cache size
    • getManagedCaches

      public final Collection<com.atlassian.cache.ManagedCache> getManagedCaches()
      Specified by:
      getManagedCaches in interface com.atlassian.cache.CacheManager
      Overrides:
      getManagedCaches in class com.atlassian.cache.impl.AbstractCacheManager
    • getOrCreateCache

      protected final <K, V> com.atlassian.cache.ManagedCache getOrCreateCache(String name, com.atlassian.cache.Supplier<ConfluenceCache<K,V>> factory)
    • getOrCreateCachedReference

      protected final <V> com.atlassian.cache.ManagedCache getOrCreateCachedReference(String name, com.atlassian.cache.Supplier<ConfluenceCachedReference<V>> factory)
    • getManagedCache

      public final com.atlassian.cache.ManagedCache getManagedCache(String cacheName)
      Specified by:
      getManagedCache in interface com.atlassian.cache.CacheManager
      Overrides:
      getManagedCache in class com.atlassian.cache.impl.AbstractCacheManager