Reputation: 1059
I want to dynamically change the configuration of the EhCache instance we're using, specifically the maxElementsInMemory setting. We are using EhCache 1.5 and I can see that it is possible API-wise:
cache.getCacheConfiguration().setMaxElementsInMemory(num);
But the documentation of EhCache says:
After a Cache has been started its configuration is not generally changeable. However, since Ehcache 2.0, certain aspects of cache configuration can modified dynamically at runtime...
So my question is: can I use this API in EhCache 1.5 or is it not guaranteed to work?
Thanks.
Upvotes: 0
Views: 3580
Reputation: 1526
As per Ehcache 2.8, this is possible:
Cache cache = manager.getCache("sampleCache");
CacheConfiguration config = cache.getCacheConfiguration();
config.setTimeToIdleSeconds(60);
config.setTimeToLiveSeconds(120);
config.setmaxEntriesLocalHeap(10000);
config.setmaxEntriesLocalDisk(1000000);
Upvotes: 0
Reputation: 1652
There are only certain properties you can modify (see Modifying Ehcache configuration at runtime), maxElementsInMemory should be one of them... for me that works in ehcache 2.4!
Upvotes: 1