Does ehcache support multi-threading by default or does it require any configuration changes? On multi threading my application with Ehcache i found that the DB hit count is actually increasing i.e. there is no global cache available for all the threads despite the fact that my cache's are all Singletons. Any suggestions?
This may help answer your question, from the FAQ:
Is it thread safe to modify Element values after retrieval from a Cache?
Remember that a value in a cache element is globally accessible from multiple threads. It is inherently not thread safe to modify the value. It is safer to retrieve a value, delete the cache element and then reinsert the value.
(emphasis added by me)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With