Henley Wing Chiu
Henley Wing Chiu

Reputation: 22535

Does Oracle Coherence support bulk delete operations?

Right now I am sending 10,000 delete operations to a Coherence server sequentially. As a result, there are 10,000 network round trips. Is there a way to send all delete operations in 1 bulk operation to Coherence to avoid this round trip?

I've researched the documentation and found that there's a way to execute commands in batch but only when running the coherence.sh (via bin/coherence.sh "@batch batchfile.txt"), but not sure how to do this through their C# API and/or cache-config files.

Does anyone have an example on how to do this through C# (not java)?

Upvotes: 3

Views: 836

Answers (3)

Paul Creasey
Paul Creasey

Reputation: 28874

cache.InvokeAll(filter, new ConditionalRemove(AlwaysFilter.INSTANCE));  

or

cache.InvokeAll(colKeys, new ConditionalRemove(AlwaysFilter.INSTANCE)); 

Upvotes: 0

Yuval Itzchakov
Yuval Itzchakov

Reputation: 149598

According to this documentation, this is the proper C# interface for what you need:

AbstractCacheStore.EraseAll Method:

Remove the specified keys from the underlying store if present.

Namespace:

Tangosol.Net.Cache Assembly: Coherence (in Coherence.dll) Version: 12.1.2.0 (12.1.2.0) Collapse imageSyntax

public void EraseAll(ICollection keys)

The implementation of this method calls Erase(Object) for each key in the supplied ICollection. Once erased successfully, a key is removed from the ICollection (if possible). Note: For many types of persistent stores, a single erase operation is as expensive as a bulk erase operation; therefore, subclasses should override this method if possible.

It looks that even the underlying API that erases the whole collection does so by calling Erase on each value. Though, Oracle Coherence is an in-memory cache, so it isn't actually going over the wire 10,000 times to erase the keys, its accessing it in memory.

Upvotes: 0

durron597
durron597

Reputation: 32343

I think you want AbstractCacheStore.eraseAll(Collection colKeys)

From the documentation:

If you want to implement read/write caching, you must extend com.tangosol.net.cache.AbstractCacheStore (or implement the interface com.tangosol.net.cache.CacheStore), which adds the following methods:

public void erase(Object oKey);
public void eraseAll(Collection colKeys);
public void store(Object oKey, Object oValue);
public void storeAll(Map mapEntries);

The method erase() should remove the specified key from the external data source. The method store() should update the specified item in the data source if it exists, or insert it if it does not presently exist.

After the CacheLoader/CacheStore is implemented, it can be connected through the coherence-cache-config.xml file.

Upvotes: 0

Related Questions