Coherence Check Cache Data Example

In this example we are connecting to the cache and pulling data’s from the cache and iterate through all its keys to get the value:

  • CheckAllCachesDatas.java:
import com.tangosol.net.NamedCache;
import com.model.trade.ExecutionModel;

public class CheckAllCachesDatas {
	
	@SuppressWarnings("unchecked")
	public void checkAllCachesDatas() {
		
		NamedCache cache = (NamedCache) CacheRegistry.getNamedCache("Executions");
	
		Set<ExecutionModel> keysetEx = cache.keySet();
		System.out.println(keysetEx.size());
		
		for (Object object : keysetEx) {
			try {
				ExecutionModel obj2 = (ExecutionModel)cache.get(object.toString());
				System.out.println(obj2);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

}

Leave a Reply

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