u6f6o
u6f6o

Reputation: 2190

How to configure near cache in local mode

On this page I found that it probably makes sense to use the local mode for hibernate in order to gain performance:

In the local mode, when you read from the cache, it will always be local and updates get invalidated). For some use cases, this is a high performance way to deploy Hazelcast as a Second Level cache because entities are guaranteed to be local and in-memory.

As far as I understand, instead of distributing the maps in the cluster, hazelcast uses topics to invalidate the local maps on the different cluster nodes. Currently we use a server-client mode instead and define our client near caches as following:

<near-cache name="one.of.our.Entities">
    <max-size>25000</max-size>
    <time-to-live-seconds>0</time-to-live-seconds>
    <max-idle-seconds>0</max-idle-seconds>
    <eviction-policy>LFU</eviction-policy>
    <invalidate-on-change>true</invalidate-on-change>
    <in-memory-format>OBJECT</in-memory-format>
</near-cache>

Since for the local mode I anyways have a local map only though, is there still a need to define a near cache or could I probably use OBJECT in-memory format for these local maps?

Upvotes: 1

Views: 567

Answers (1)

u6f6o
u6f6o

Reputation: 2190

I started debugging the whole thing a bit. There is a class called LocalRegionCache which holds a cache field represented by a ConcurrentHashMap. The map uses the normal map configuration for max-size limitations etc.

Luckily no serialization happened so far (on the map entries), so I guess it's already working like the near cache and does not need any further near cache configuration.

Upvotes: 1

Related Questions