Advertise with us

Our eBooks

How to iterate over an Infinispan cache

The simplest way to iterate over an Infinispan Cache is by means of iterating over its Set of entries, as in the following example, which uses JDK 1.8 (Lambda expression) style:

cache.entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));

 The above example will print cache statistics for the whole cluster. On the other hand, if you want to display Cache entries just for the current node, then you could use the Flag.SKIP_REMOTE_LOOKUP on the Cache object:

.entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));

 See the full example:

© 2021 All Rights Reserved.

Please publish modules in offcanvas position.