public abstract class AbstractCacheWriter extends Object implements CacheWriter
CacheWriter methods.
The write(net.sf.ehcache.Element), writeAll(java.util.Collection<net.sf.ehcache.Element>), delete(net.sf.ehcache.CacheEntry) and deleteAll(java.util.Collection<net.sf.ehcache.CacheEntry>) methods throw
UnsupportedOperationException unless they're overridden by the class that is extending
AbstractCacheWriter. Classes that are extending this abstract base class should make sure that the
appropriate cache writer operation methods are implemented with their application functionalities.| Constructor and Description |
|---|
AbstractCacheWriter() |
| Modifier and Type | Method and Description |
|---|---|
CacheWriter |
clone(Ehcache cache)
Creates a clone of this writer.
|
void |
delete(CacheEntry entry)
Delete the cache entry from the store
|
void |
deleteAll(Collection<CacheEntry> entries)
Remove data and keys from the underlying store for the given collection of keys, if present.
|
void |
dispose()
Providers may be doing all sorts of exotic things and need to be able to clean up on
dispose.
|
void |
init()
Notifies writer to initialise themselves.
|
void |
throwAway(Element element,
SingleOperationType operationType,
RuntimeException e)
This method will be called, whenever an Element couldn't be handled by the writer and all
the
retryAttempts have been tried. |
void |
write(Element element)
Write the specified value under the specified key to the underlying store.
|
void |
writeAll(Collection<Element> elements)
Write the specified Elements to the underlying store.
|
public void write(Element element) throws CacheException
write in interface CacheWriterelement - the element to be writtenCacheExceptionpublic void writeAll(Collection<Element> elements) throws CacheException
writeAll in interface CacheWriterelements - the Elements to be writtenCacheExceptionpublic void delete(CacheEntry entry) throws CacheException
delete in interface CacheWriterentry - the cache entry that is used for the delete operationCacheExceptionpublic void deleteAll(Collection<CacheEntry> entries) throws CacheException
deleteAll in interface CacheWriterentries - the entries that have been removed from the cacheCacheExceptionpublic void throwAway(Element element, SingleOperationType operationType, RuntimeException e)
retryAttempts have been tried.
When batching is enabled all the elements in the failing batch will be passed to this methods
Try to not throw RuntimeExceptions from this method. Should an Exception occur, it will be logged, but the element will be lost anyways.
throwAway in interface CacheWriterelement - the Element that triggered the failure, or one of the elements part of the batch that failedoperationType - the operation we tried to executee - the RuntimeException thrown by the Writer when the last retry attempt was being executedpublic CacheWriter clone(Ehcache cache) throws CloneNotSupportedException
clone in interface CacheWriterCloneNotSupportedException - if the extension could not be cloned.public void init()
init method should be able
to handle that situation. Unless you perform this multiple usage of a cache writer yourself,
Ehcache will not do this though. So in the majority of the use cases, you don't need to do
anything special.init in interface CacheWriterpublic void dispose()
throws CacheException
dispose in interface CacheWriterCacheExceptionCopyright © 2003-2014 Terracotta, Inc.. All Rights Reserved.