Package org.cache2k.io
Interface CacheWriter<K,V>
-
- All Superinterfaces:
Customization,DataAware<K,V>,DataAwareCustomization<K,V>
public interface CacheWriter<K,V> extends DataAwareCustomization<K,V>
Writer for write-through configurations. Any mutation of the cache via theCacheinterface, e.g.Cache.put(Object, Object)orCache.remove(Object)will cause a writer call.- Since:
- 2
- Author:
- Jens Wilke
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddelete(K key)Called when a mapping is removed from the cache.voidwrite(K key, V value)Called when the value was updated or inserted into the cache.
-
-
-
Method Detail
-
write
void write(K key, V value) throws Exception
Called when the value was updated or inserted into the cache.Calling cache operations: It is illegal to call any cache methods from this method. This may have an undesired effect and can cause a deadlock.
- Parameters:
key- key of the value to be written, never null.value- the value to be written, may be null if null is permitted.- Throws:
Exception- if an exception occurs, the cache update will not occur and this exception will be wrapped in aCacheWriterException
-
delete
void delete(K key) throws Exception
Called when a mapping is removed from the cache. The removal was done byCache.remove(K)orCache.removeAll(). An expiry does not trigger a call to this method.- Parameters:
key- key of the value removed from the cache, never null.- Throws:
Exception- if an exception occurs, the cache update will not occur and this exception will be wrapped in aCacheWriterException
-
-