Search code examples
spring-boothazelcasthazelcast-imap

Hazelcast as cache with Spring Boot


I have tried Hazelcast as cache (using @Cacheable and @CacheEvict) with Spring Boot (using hazelcast-spring artifact in Spring boot 1.5.2.RELEASE) and my application crashed because it ran out of memory. I have two questions:

1) Default behaviour seems to be filling all the cache until there is no more memory and then throw an exception. Am I right? It looks weird to me that there is no default LRU o LFU criteria for caches.

2) How can I configure in hazelcast.xml max size, ttl, etc for ALL maps in my application? (Something like a default config and then extend it for particular maps)

Thanks.


Solution

  • @italktothewind

    1 - By default, there is no eviction configured, either time or size based. But you can configure any of them or both. Please see http://docs.hazelcast.org/docs/latest-development/manual/html/Distributed_Data_Structures/Map/Map_Eviction.html

    2 - If you configure the default map & no special config per map, then all maps will share the same config. But if you decide to add a map specific config, then you need to add all necessary config options since it won't inherit the other non-configured params from default map config.