is EhCache need specific configuration to store on disk?

Viewed 63

I tried to use EhCache to store 100000 strings when every string is a Json which weights 4MB (Total 400GB). (and the key is number from 1 to 100000)
To solve it I used the EhCache with this programmatically configuration:

CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
                .with(CacheManagerBuilder.persistence(<PATH_TO_PERSISTENCE_DIR))
                .withCache("session", CacheConfigurationBuilder.newCacheConfigurationBuilder(Integer.class, String.class,
                        ResourcePoolsBuilder.heap(1000)
                                .disk(600, MemoryUnit.GB)
                ).withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(20))))
                .build();

        cacheManager.init();
        Cache<Integer, String> sessionCache = cacheManager.getCache("session", Integer.class, String.class);

The resolution is after ~ 12GB the Cache throw OOM Exception and can't add new elements.

As I'm doing something wrong? There is limitation which I didn't saw? (My computer have 32GB of ram and ~1TB of free space)

0 Answers
Related