Package org.apache.wiki.cache
Class EhcacheCachingManager
- java.lang.Object
-
- org.apache.wiki.cache.EhcacheCachingManager
-
- All Implemented Interfaces:
Initializable,CachingManager
public class EhcacheCachingManager extends java.lang.Object implements CachingManager, Initializable
Ehcache-basedCachingManager.
-
-
Field Summary
-
Fields inherited from interface org.apache.wiki.cache.CachingManager
CACHE_ATTACHMENTS, CACHE_ATTACHMENTS_COLLECTION, CACHE_ATTACHMENTS_DYNAMIC, CACHE_DOCUMENTS, CACHE_PAGES, CACHE_PAGES_HISTORY, CACHE_PAGES_TEXT, PROP_CACHE_CONF_FILE, PROP_CACHE_ENABLE, PROP_USECACHE_DEPRECATED
-
-
Constructor Summary
Constructors Constructor Description EhcacheCachingManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanenabled(java.lang.String cacheName)Checks if the requested cache is enabled or not.<T,E extends java.lang.Exception>
Tget(java.lang.String cacheName, java.io.Serializable key, CheckedSupplier<T,E> supplier)Returns an item from a cache.CacheInfoinfo(java.lang.String cacheName)Retrieves cache usage information.voidinitialize(Engine engine, java.util.Properties props)Initializes this Engine component.java.util.List<java.lang.String>keys(java.lang.String cacheName)Returns the list of keys from elements present in a cache.voidput(java.lang.String cacheName, java.io.Serializable key, java.lang.Object val)Puts an item on a cache.voidremove(java.lang.String cacheName, java.io.Serializable key)Removes an item from a cache.voidshutdown()Shuts down the underlying cache manager
-
-
-
Constructor Detail
-
EhcacheCachingManager
public EhcacheCachingManager()
-
-
Method Detail
-
shutdown
public void shutdown()
Shuts down the underlying cache manager- Specified by:
shutdownin interfaceCachingManager
-
initialize
public void initialize(Engine engine, java.util.Properties props) throws WikiException
Initializes this Engine component. Note that the engine is not fully initialized at this point, so don't do anything fancy here - use lazy init, if you have to.
- Specified by:
initializein interfaceInitializable- Parameters:
engine- Engine performing the initialization.props- Properties for setup.- Throws:
WikiException- if an exception occurs while initializing the component.
-
enabled
public boolean enabled(java.lang.String cacheName)
Checks if the requested cache is enabled or not.- Specified by:
enabledin interfaceCachingManager- Parameters:
cacheName- The cache to be queried.- Returns:
trueif the cache is enabled,falseotherwise.
-
info
public CacheInfo info(java.lang.String cacheName)
Retrieves cache usage information.- Specified by:
infoin interfaceCachingManager- Parameters:
cacheName- The cache to be queried.- Returns:
- cache usage information, or
nullif the requested cache is not enabled.
-
keys
public java.util.List<java.lang.String> keys(java.lang.String cacheName)
Returns the list of keys from elements present in a cache.- Specified by:
keysin interfaceCachingManager- Parameters:
cacheName- The cache to be queried.- Returns:
- list of keys from elements present in a cache.
-
get
public <T,E extends java.lang.Exception> T get(java.lang.String cacheName, java.io.Serializable key, CheckedSupplier<T,E> supplier) throws E extends java.lang.Exception
Returns an item from a cache. If it is not found on the cache, try to retrieve from the provided supplier. If found there, put the value in the cache, and return it. Otherwise, returnnull.- Specified by:
getin interfaceCachingManager- Parameters:
cacheName- The cache in which the item lives.key- item's identifier.supplier- if the element is not cached, try to retrieve from the cached system.- Returns:
- The requested item or
nullif either the cache is not enabled or the item is not present on the cache / cached service. - Throws:
E- the supplier may throw a checked exception, which is propagated upwards.E extends java.lang.Exception
-
put
public void put(java.lang.String cacheName, java.io.Serializable key, java.lang.Object val)
Puts an item on a cache.- Specified by:
putin interfaceCachingManager- Parameters:
cacheName- The cache in which the item will live.key- item's identifier.val- item to insert in the cache.
-
remove
public void remove(java.lang.String cacheName, java.io.Serializable key)
Removes an item from a cache.- Specified by:
removein interfaceCachingManager- Parameters:
cacheName- The cache in which the item to be removed lives.key- item's identifier.
-
-