In Hazelcast IMap when I delete a certain key and immediately add the same key with different data and then get that data in less than a second, Hazelcast IMap return old data.
For example
1) I am deleting a key with value {key : String, value : serialized object}
2) Now I add the value against the same key in less than a second with value {key : String, value : serialized object}
3) At this time I try to get the key get{key : String}
which return the same value as in point 1.
To avoid this error(workaround), I have tried adding Thread.sleep(1000L). This seems to work but doesn't provide consistency.
Also used evict, remove methods for IMap. Nothing seems to work in this case.
Hazelcast.xml configuration is default config. At Client side hazelcastClient.xml is also with default config.
method api()
{
if(userIsAlreadyLogin)
{
forcelogout()
}
handleValidUserlogin()
}
method forcelogout()
{
removeUserDetails()
}
removeUserDetails()
{
IMap.lock()
IMap.delete(key : String, value : serialized object)
IMap.unlock()
}
method handleValidUserlogin()
{
IMap.get() //Printing values after deletion
IMap.put(key : String, value : serialized object)
IMap.get()
}