com.atlassian.cache.ehcache
Class EhCacheManager

java.lang.Object
  extended by com.atlassian.cache.impl.AbstractCacheManager
      extended by com.atlassian.cache.ehcache.EhCacheManager
All Implemented Interfaces:
CacheFactory, CacheManager, MBeanRegistrar

public class EhCacheManager
extends AbstractCacheManager
implements MBeanRegistrar

Maintains a mapping of name -> Cache and provides factory methods for creating ad getting caches.

Since:
2.0

Field Summary
 
Fields inherited from class com.atlassian.cache.impl.AbstractCacheManager
cacheCreationLocks, caches
 
Constructor Summary
EhCacheManager()
          Creates an instance backed by a new instance of CacheManager.
EhCacheManager(net.sf.ehcache.CacheManager delegate)
          Creates an instance backed by the provided instance of CacheManager.
 
Method Summary
protected
<K,V> ManagedCache
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  ManagedCache createSimpleCache(String name, CacheSettings settings)
          Creates a cache with no loader, i.e.
<V> CachedReference<V>
getCachedReference(String name, Supplier<V> supplier, CacheSettings settings)
          Returns a Cached Reference, creating it if necessary.
 void registerMBeans(MBeanServer mBeanServer)
          Tells this object to register its JMX MBeans with the given server.
 
Methods inherited from class com.atlassian.cache.impl.AbstractCacheManager
flushCaches, getCache, getCache, getCache, getCache, getCache, getCachedReference, getCachedReference, getCachedReference, getCaches, getManagedCaches
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EhCacheManager

public EhCacheManager()
Creates an instance backed by a new instance of CacheManager.


EhCacheManager

public EhCacheManager(net.sf.ehcache.CacheManager delegate)
Creates an instance backed by the provided instance of CacheManager.

Parameters:
delegate - an Ehcache's cache manager
Method Detail

getCachedReference

public <V> CachedReference<V> getCachedReference(String name,
                                                 Supplier<V> supplier,
                                                 CacheSettings settings)
Description copied from interface: CacheFactory
Returns a Cached Reference, creating it if necessary.

Specified by:
getCachedReference in interface CacheFactory
Parameters:
name - the name of the Cached Reference
supplier - the supplier for value to be cached, called if the value needs to be generated
settings - specifies the required cache settings
Returns:
the Cached Reference

createSimpleCache

protected ManagedCache createSimpleCache(String name,
                                         CacheSettings settings)
Description copied from class: AbstractCacheManager
Creates a cache with no loader, i.e. one populated via explicit puts.

Specified by:
createSimpleCache in class AbstractCacheManager
Parameters:
name - the name to give the cache (required)
Returns:
a non-null cache

createComputingCache

protected <K,V> ManagedCache createComputingCache(String name,
                                                  CacheSettings settings,
                                                  CacheLoader<K,V> loader)
Description copied from class: AbstractCacheManager
Creates a cache that upon a miss is able to populate itself using the loader.

Specified by:
createComputingCache in class AbstractCacheManager
Returns:
a non-null cache

registerMBeans

public void registerMBeans(@Nullable
                           MBeanServer mBeanServer)
Description copied from interface: MBeanRegistrar
Tells this object to register its JMX MBeans with the given server. What beans are registered, if any, is up to the implementation.

Specified by:
registerMBeans in interface MBeanRegistrar
Parameters:
mBeanServer - the server with which to register the MBeans (ignored if null)


Copyright © 2014 Atlassian. All Rights Reserved.