3

I'm using hazelcast to store data that are important for a small time window (maybe 30 to 50 min, but no more than 60 min). The older the entry, the less important it is, meaning if we could get rid of some entries to avoid an OutOfMemory would be the older entries.

I configured the TTL for those entries to 60 min but when running out of memory I would like to reliable get rid of oldest entries first even they are not expired.

I checked the configuration of EvictionPolicy.LRU but configuring it I could see that some recently added entries to the map are getting evicted. I suppose that is due to the sampling algorithm used to elect entries for eviction as explained here.

Is there any implementation of distributed objects that covers this use-case?

Francisco Spaeth
  • 23,493
  • 7
  • 67
  • 106

1 Answers1

1

Starting from Hazelcast 3.7, you will be able to define a custom eviction policy and implement any algorithm. You can find a sample here.

Thank you

Vik Gamov
  • 5,446
  • 1
  • 26
  • 46
  • hey that is great, will check that out! Is it expected that the `LRU` implementation in some situations evicts the last added entry? I could see such behavior by adding a entry listener just printing something when an entry is added or evicted, in some cases I could see the eviction of a recently added entry and keeping entries not being accessed for more than hours (using `hz 3.6.4`). – Francisco Spaeth Aug 09 '16 at 18:09
  • Eviction of last added entry should not be a problem any more in 3.7 release. Please see this: https://github.com/hazelcast/hazelcast/issues/4334 – mrck Aug 12 '16 at 14:32