There are scenarios when you would like to fetch/update data in the cache in bulk, e.g. an application can load customer information in bulk at the start. Bulk operations are designed to achieve better performance as they are executed as a single operation on the server. Retrieving 100 cache items in a single bulk operation works manifold faster than retrieving them through 100 individual get calls.
Failures in Bulk Operations
Although bulk operation executes as a single operation, failure of operations constituting the bulk operation are treated individually, e.g. if you perform a bulk add operation with 100 cache items and 20 cache items already exist in the cache, then only those 20 cache items will not be added to the cache. The remaining 80 cache items will be added to the cache. As a result, a dictionary consisting of failed operations is returned by the cache.
Avoid Large Bulk Operations
There is no limit on how many operations can be combined in a single bulk operation. However, it is recommended to avoid larger bulk operations as it can raise the memory usage on both the application and cache servers due to serialization/deserialization of a large amount of the cache data in a single cache operation request/response.
How Bulk Operation Works
Bulk operations behave in a different way for different topologies:
- Mirror and Replicated Cache
In mirror topology, the client only communicates with the active node, while passive node is the replica of active node and is used for backup facility.
In replicated topology, write operations are performed on all the nodes in parallel fashion.
Bulk operations in these topologies are sent to the specific node where the client is connected. Thus the bulk operation boosts performance by decreasing network trips to remote server.
- Partitioned and Partitioned-of-Replica Cache
Bulk operations are optimized in case of partitioned or partitioned-replicated topology. In these topologies, the key-distribution map is maintained to distribute keys over multiple nodes. On the client side, this map is used to optimize bulk operations.
When data is updated or fetched, the bulk operation bundles the collection of key-value pairs based on the key-distribution map. These bundles are sent to particular nodes on the remote server. On getting a response, bulk operation merges these responses and returns the accumulative result to the client’s application thus, optimizing the operations and increasing performance of the application.
In This Section
Adding a Collection to Cache
Explains how to add a collection of data into cache.
Updating a Collection to Cache
Explains how to update a collection of data into cache.
Retrieving a Collection from Cache
Explains how to fetch a collection of data from cache.
Removing a Collection from Cache
Explains how to remove a collection of data from cache.
Deleting a Collection to Cache
Explains how to delete a collection of data from cache.