We want to cache, using Ehcache, sensitive data that should never be stored to disk (data can only reside in main memory). It is the kind of data that is illegal for it to be stored on disk at all and therefore needs to be treated with a certain caution.
We are already using Ehcache (both with and without terracotta) for common caching purposes.
I know that Ehcache provides the option to cache on both to main memory and to disk, and additionally it allows to overflowtodisk when using main memory.
I am new to Ehcache, and would like to know of how to configure Ehcache so as to guarantee that this particular cache never touches the disk. (we are currently mostly using default configuration) Additionally it would be nice to have a way to confirm where data is being stored once we have the implementation running (to confirm that no data is not stored the disk).
As far as I know, persistence to disk has to be explicitely enabled. See the documentation here. If you haven't already added such configuration, I doubt things are getting stored to disk by default. Check your ehcache config, do you see anything related to persistence or
CacheWriter
attachments to your caches?I would have said that once your service is running, you can obtain the cache configurations via JMX to check whether there is disk persistence and, if yes, where it is persisting. You can enable JMX this way and can check for yourself:
For example, the bean net.sf.cache/CacheConfiguration/CacheManager/cache/DiskPersistent tells you whether disk persistence is enabled or not. However, persistence can be done via
CacheWriter
as well. To find this out, you cannot use JConsole, but you have to programmatically attach to the MBeanServer and obtain the attribute net.sf.ehcache/Cache/CacheManager/cache/CacheConfiguration. This will return anet.sf.ehcache.management.CacheConfiguration
instance which should tell you about the registered CacheWriter, and hopefully the config it is using. (I haven't tried this myself.)Also, if data confidentiality is very important to you, then you should also consider encrypting your data (in cache, and over the wire.)