Hazelcast Map Expire Listener on key, race condition

Hazelcast Map Expire Listener on key, race condition

我在 hazelcast 成员上有 IMapLong 密钥的某些部分具有过期时间 (TTL)。

为此,我正在注册 EntryExpiredListener on key using addEntryListener(MapListener, K, boolean)

一切正常,但我有疑问。

documentation 所述:

With the above approach, there is the possibility of missing events between the creation of the instance and registering the listener. To overcome this race condition, Hazelcast allows you to register listeners in configuration.

如果我在key上注册EntryExpiredListener,会不会遇到上面描述的'missing events'?

如果它在成员上并且您将侦听器标记为本地(因此每个成员仅接收本地扩展事件)并在配置中定义,您不会因为事件对每个成员都是本地的。

如果您在创建实例后注册侦听器,在分配分区之后和注册侦听器之前,某些数据可能会过期。这就是为什么上面的语句说你需要在配置中定义监听器来防止这种情况。