cachingdistributed-cachingoracle-coherencejcache

Fetching all keys from Partitioned Coherent Cache


I am doing a project and my requirement is to basically implement a Coherence Cache Dashboard. The basic idea is to fetch all the keys stored in the Coherent Cache. Is there a command or any other way to fetch all cache keys from distributed coherent cache?

    public void printAllCache(){

    Cache<String, String> cache = cacheManager.getCache(CACHENAME, 
      String.class, String.class);

    Iterator<Cache.Entry<String,String>> allCacheEntries= cache.iterator();
    while(allCacheEntries.hasNext()){
      Cache.Entry<String,String> currentEntry = allCacheEntries.next();
      System.out.println("Key: "+currentEntry.getKey()+" Value: "+ 
      currentEntry.getValue());
    }

      return returnProperties;

    }

By doing this, i can iterate over cache keys created by the current cache manager. But, how can I find keys created by other cache managers in a partitioned coherent cache?


Solution

  • This is a simple command:

     NamedCache<String, String> cache = CacheFactory.getCache(CACHENAME, String.class, String.class);
     Set<String> keys = cache.keySet();