Product Documentation : Ehcache Developer Guide : Write-Through and Write-Behind Caches : API
API
CacheLoaders are exposed for API use through the cache.getWithLoader(...) method.
CacheWriters are exposed with cache.putWithWriter(...) and cache.removeWithWriter(...) methods. The code below show the method signature for the cache.putWithWriter(...) method. For the complete API, see the Cache Javadoc.
/**
* Put an element in the cache writing through a CacheWriter. If no CacheWriter
* has been set for the cache, then this method has the same effect as
* cache.put().
*
* Resets the access statistics on the element, which would be the case if
* it has previously been gotten from a cache, and is now being put back.
*
* Also notifies the CacheEventListener, if the writer operation succeeds, that:
*
* - the element was put, but only if the Element was actually put.
* - if the element exists in the cache, that an update has occurred, even if
* the element would be expired if it was requested
*
*
* @param element An object. If Serializable it can fully participate in
* replication and the DiskStore.
* @throws IllegalStateException if the cache is not
* {@link net.sf.ehcache.Status#STATUS_ALIVE}
* @throws IllegalArgumentException if the element is null
* @throws CacheException
*/
void putWithWriter(Element element) throws IllegalArgumentException,
IllegalStateException, CacheException;
Copyright © 2014 Software AG, Darmstadt, Germany.

Product Logo |   Feedback