javahazelcasthazelcast-imap

Hazelcast, check if particular key is available in hazel cast map which is configured with mapLoader(read through)


We have implemented read-through using MapLoader with load key functionality which loads specific keys and value from database to Hazelcast map as a part of read-through. My question is if We want check if particular key is available in hazelcast map, how can I achieve that without read-through?

we tried using IMap.contains(key), but Hazelcast performs read-through and loads the data via MapLoader when key is not available. which we do not want.


Solution

  • You can do IMap.getEntryView(key), which doesn't invoke read-through.

    If you're on a newer version of Hazelcast and have SQL, you can also do:

    SELECT * FROM map WHERE __key LIKE 'key%'