Ananth
Ananth

Reputation: 206

What is the alternative for cache-value in non-spring implementation of hazelcast?

I recently started working in Hazelcast and I found that the get(Key) method of Map only returns the cloned value. But I would require the original object rather than the clone. While searching some of the questions here, I found out that there is something called cache-value = "true" for the spring integration of Hazelcast which will cache the object version of the value and will return the same copy on local reads. How to attain this functionality without spring as I'm using only core java?

Upvotes: 0

Views: 553

Answers (1)

Nick Holt
Nick Holt

Reputation: 34301

Hazelcast is a distributed cache; distributing the keys and values around the nodes in the cluster will require they are serialized and hence you should not expect to get the exact object back that you put in.

In general, when using a distributed cache, all your key and value objects need to implement equals (and hashcode) so that two seperate instances that are symantically equal can be compared. Objects that are not serializable (sockets, JDBC connections, etc) are not suitable for being stored in a distributed cache and if this is the problem you are trying to solve you should just use a java.util.Map.

Upvotes: 2

Related Questions