• Bug
  • Status: Resolved
  • 2 Major
  • Resolution: Won't Fix
  • ehcache-core
  • ljacomet
  • Reporter: lpouzac
  • April 16, 2013
  • 0
  • Watchers: 5
  • June 06, 2013
  • May 14, 2013

Description

If I set maxElementsInMemory to 0, I get this warning :

2013-04-16 13:10:48,553;WARN ;CacheConfiguration;Cache: testService has a maxElementsInMemory of 0. This might lead to performance degradation or OutOfMemoryError at Terracotta client.From Ehcache 2.0 onwards this has been changed to mean a store with no capacity limit. Set it to 1 if you want no elements cached in memory

But if I set it to 1, one element is cached in memory and not zero.

Can you change using 0 to disable cache and -1 for unlimited objets stored ?

Thanks

Comments

James House 2013-04-22

Changing the meaning of “0” would break long-time compatibility for millions of users. Also, magic numbers are a pain and confusing in general - as this very issue attests.

There is an explicit ‘disable’ property for caches.

Pouzac Lucas 2013-04-22

Could you add ‘disable’ property on cache element from XSD ?

...

James House 2013-04-22

Please evaluate for Vicente GA release.

Alexander Snaps 2013-04-23

I’d run this by API leads first. Personally, as a heads up, I’m against this. We shouldn’t provide multiple ways to achieve one thing. In that respect the user should call into Ehcache.setDisabled. I understand that when a third party embedded ehcache, this might be more complex (but just fetch the CacheManager this thing uses, and disable from there, at the appropriate spot while bootstrapping you app), but that’s just a flaw in someone else’s design. We should not try to account for this…

Alexander Snaps 2013-04-23

The disable prop is : Ehcache.setDisabled(bool) not on the Cache’s config. So I guess your request is to add this to CacheConfiguration as well… Something that’d need careful evaluation.

Louis Jacomet Jacomet 2013-04-24

Hello Lucas,

Could you please detail your use case and why you need a configuration option instead of a runtime option for this?

Pouzac Lucas 2013-04-24

I have two applications that have the same component. The component has multiple cache area, but one application, I need to disable only one cache area but not all.

Alexander Snaps 2013-04-24

I’d say the component would need to have a way to be told whether to use a cache or not. Also, you could have the app, while bootstrapping it, grab the CacheManager and disable all caches it knows about.

Louis Jacomet Jacomet 2013-05-14

As discussed through comments, the use case does not require this feature to be implemented.