Hazelcast 3.4: how to avoid deserialization from near cache and get original item

1.8k Views Asked by At

Starting from version 3.X Hazelcast returns copy of the original object that is stored in a distributed map with near cache enabled, as opposed to version 2.5 where original object was returned.

This behavior allowed local modifications of entries stored in the map and GET operations was fast.

Now, with version 3.X it stores binary object in near cache, and it causes deserialization on every GET, which significantly impacts performance. Is it possible to configure Hazelcast 3.4.2 Map's Near Cache to return reference to original object, and not a copy of the original entry?

2

There are 2 best solutions below

5
On BEST ANSWER

In the <near-cache> section, if you set

  • <in-memory-format>OBJECT</in-memory-format>
  • AND
  • <cache-local-entries>true</cache-local-entries>

you should get the same instance returned.

This works for both client and member.

1
On

I do not think that there is a way to get original item. To avoid deserialization you could try and set

<in-memory-format>OBJECT</in-memory-format> 

in <near-cache> configuration. This way hazelcast will store data in <near-cache> in object form and deserialization would not be needed. But I guess this will work only if you configured <near-cahce> on the client side, because if <near-cache> is on the node you will still need serialization to pass object from node to client.