如何在本地模式下配置近缓存

How to configure near cache in local mode

this 页面上,我发现使用本地模式休眠以获得性能可能是有意义的:

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.

据我了解,hazelcast 不是在集群中分发地图,而是使用主题使不同集群节点上的本地地图无效。目前我们改用服务器-客户端模式,并将我们的客户端附近的缓存定义如下:

<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>

由于对于本地模式我无论如何只有一个本地地图,是否仍然需要定义一个近缓存或者我可以为这些本地地图使用 OBJECT 内存格式吗?

我开始对整个事情进行调试。有一个名为 LocalRegionCache 的 class,它包含一个由 ConcurrentHashMap 表示的缓存字段。该贴图使用法线贴图配置来限制最大尺寸等。

幸运的是到目前为止(在地图条目上)没有发生序列化,所以我猜它已经像近缓存一样工作并且不需要任何进一步的近缓存配置。