I have to get all keys stored in IgniteCache, unfortunately this method is not implemented in Ignite. I'm using java client. I thought it is a common method, what is the reason Ignite team didn't implement it?
Is there any efficient solution for getting keys?
Thanks to @alexfedotov I created a solution for my problem, I'm positng it here, since someone may find it useful.
List<K> keys = new ArrayList<>();
cache.query(new ScanQuery<>(null)).forEach(entry -> keys.add((K) entry.getKey()));
After running this code you will receive a list with keyset.
You can get all the keys using ScanQuery with a null
predicate. It will return all the entries (key-value pairs).
As well you can use an SqlFieldsQuery like select _key from Entity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With