3.4.3. Use the Batching API
After the cache is configured to use batching, call
startBatch()
and endBatch()
on the cache as follows to use batching:
Cache cache = cacheManager.getCache();
Cache cache = cacheManager.getCache();
Example 3.1. Without Using Batch
cache.put("key", "value");
cache.put("key", "value");
When the
cache.put(key, value);
line executes, the values are replaced immediately.
Example 3.2. Using Batch
When the line
cache.endBatch(true
);
executes, all modifications made since the batch started are replicated.
When the line
cache.endBatch(false
);
executes, changes made in the batch are discarded.