Entry Processor Overview
The Entry Processor has been introduced in NCache to allow users to execute their code (invokable functions) against a set of cache entries on the server side. NCache fully supports precise execution of Entry Processor regardless of the caching topology being used.
In the usual update scenario, you actually make two network trips to and from the cache. One, to fetch the element to be modified, and the second to save the updated value back into the cache. This is where Entry Processors come in handy: you can modify cache entries on the server side without involving these entries to travel over the network for fetch and update operations. This results in fairly noticeable performance improvement because of the avoidance of network trips and unnecessary consumption of resources.
In case of partitioned topologies, entries are processed on the same node where they reside. It is recommended to use ‘Object’ data format to avoid deserialization cost every time an entry is processed.
How does Entry Processor work?
Entry Processor can be executed on a single cache entry or a set of cache entries. It is particularly useful if you want to process your cache data on server side.
Once you invoke your Entry Processor to be executed on the server side, the data is processed according to user specified logic on server side. Using Entry Processor, you do not have to worry about concurrency as it allows user to apply a low-level lock on the cache entries it is processing. In case the required entry is locked by the client before executing entry processor, EntryProcessor provides an option to ignore the lock and access it.
Entry Processors work in parallel across the cluster, on the nodes that contain the entries. This helps in reducing a significant amount of network burden as the extra trips of fetching data to execute the code and saving it back to the cache is eliminated.
The values may be changed or removed and it is up to you how you treat the resultant data:
Fetch the data without saving the change in the cache and use it in your application locally.
Save the modification in the cache.
Update the modification in both the cache and data source through ReadThru and WriteThru operations.
Make sure that the
EntryProcessor class which you implement and the resultant
values are Serializable before any operation takes place.