Coherence Clear Cache Example

There are many commands available to to clear cache. Below is sample java program which connect to the cache and clears all its data:

  • CleanCaches.java:
import java.util.Set;

import com.tangosol.net.NamedCache;

public class CleanCaches {
	
	@SuppressWarnings("rawtypes")
	public void cleanCache() {
		
		NamedCache cache = (NamedCache) CacheRegistry.getNamedCache("Products");		
		
		cache.clear();		
		Set keyset = cache.keySet();		
		System.out.println(keyset);
		
	}

}

Leave a Reply

Your email address will not be published. Required fields are marked *