ICacheWriter Interface |
Note: This API is now obsolete.
Namespace: GemStone.GemFire.Cache
The ICacheWriter type exposes the following members.
Name | Description | |
---|---|---|
![]() | BeforeCreate |
Called before an entry is created. Entry creation is initiated by a
Create, a Put, or a Get.
|
![]() | BeforeDestroy |
Called before an entry is destroyed.
|
![]() | BeforeRegionClear |
Called before this region is cleared.
|
![]() | BeforeRegionDestroy |
Called before this region is destroyed.
|
![]() | BeforeUpdate |
Called before an entry is updated. The entry update is initiated by a
Put or a Get that causes the loader to update an existing entry.
|
![]() | Close |
Called when the region containing this callback is destroyed, when
the cache is closed.
|
A distributed region will typically have a single cache writer. If the application is designed such that all or most updates to a region occur on a node, the cache writer for the region should be installed at that node.
A cache writer is defined in the RegionAttributes.
Cache writer invocations are initiated by the node where the entry or region modification occurs.
Before a region is updated via a put, create, or destroy operation, GemFire will call an ICacheWriter that is installed anywhere in any participating cache for that region, preferring a local ICacheWriter if there is one. Usually there will be only one ICacheWriter in the distributed system. If there are multiple ICacheWriters available in the distributed system, the GemFire implementation always prefers one that is stored locally, or else picks one arbitrarily. In any case, only one ICacheWriter will be invoked.
The typical use for a ICacheWriter is to update a database. Application writers should implement these methods to execute application-specific behavior before the cache is modified.
Note that cache writer callbacks are synchronous callbacks and have the ability to veto the cache update. Since cache writer invocations require communications over the network, (especially if they are not co-located on the nodes where the change occurs) the use of cache writers presents a performance penalty.
The ICacheWriter is capable of aborting the update to the cache by throwing a CacheWriterException. This exception or any runtime exception thrown by the ICacheWriter will abort the operation, and the exception will be propagated to the initiator of the operation, regardless of whether the initiator is in the same process as the ICacheWriter.