FAQ : Questions about Troubleshooting : General Ehcache
General Ehcache
I have created a new cache and its status is STATUS_UNINITIALISED. How do I initialize it?
You need to add a newly created cache to a CacheManager before it gets initialized. Use code like the following:
CacheManager manager = CacheManager.create();
Cache myCache = new Cache("testDiskOnly", 0, true, false, 5, 2);
Why does Ehcache 1.6 use more memory than 1.5?
ConcurrentHashMap does not provide an eviction mechanism. We add that ourselves. For caches larger than 5000 elements, we create an extra ArrayList equal to the size of the cache which holds keys. This can be an issue with larger keys. An optimization which cache clients can use is:
To reduce the number of key instances in memory to just one per logical
key, all puts to the underlying ConcurrentHashMap could be replaced by
map.put(pool.replace(key), value), as well as keyArray.set(index,
You can take this approach when producing the keys before handing them over to EhCache.
Even with this approach, there is still some added overhead consumed by a reference consumed by each ArrayList element. Update: Ehcache 2.0 will introduce a new implementation for MemoryStore based on a custom ConcurrentHashMap. This version provides fast iteration and does away with the need for the keyArray thus bringing memory use back down to pre 1.6 levels. And with other memory optimizations made to Element in 1.7, memory use will actually be considerably lower than pre 1.6 levels.
Why did a crashed standalone Ehcache node using disk store not come up with all data intact?
It was configured for temporary disk swapping that is cleared after a restart. For crash-resilient persistence, configure your cache with persistenceStrategy="localRestartable", or use distributed cache, which is backed by the Terracotta Server Array.
I added a cache on Client 1, but I can't see it on Client 2. Why not?
A clustered cache created programmatically on one application node does not automatically appear on another node in the cluster. The expected behavior is that caches (whether clustered or not) added programmatically on one client are not visible on other clients. CacheManagers are not clustered, only caches are. So if you want to add a cache programmatically, you would have to add it on all the clients. If that cache is configured to be Terracotta clustered, then it will use the same store, and changes applied to cache entries on one client will automatically reflect on the second client.
Copyright © 2010-2015 Software AG, Darmstadt, Germany.

Product Logo |   Feedback