Hello,
For EHCache the default disk cache file location is something like this:
/tmp/org.my.package.SomeClassFile.data.
This doesn't work in an Enterprise environment. One example of this is what do you do if you have multiple instances of the same app running on the same server?
There are two ways to solve this:
- modify the java.tmp.dir, user.home, or the user.dir system properties
- write your own CacheProvider class that initializes the EhCache with whatever values you want.
- modify the /ehcache.xml file
Unfortunately the environment I work in has a tight security policy that prevents the changing of System.properties once they are set. Also, since I need to be able to run multiple instances of the same app on the same machine I need to create unique cache directories at run time. That leaves the unfortunate choice of having to create my own CacheProvider.
I would like to suggest a few fixes to make this easier:
- in org.hibernate.cache.EhCacheProvider, make non-static variables (like 'manager') protected. This simple change means instead of having to copy the entire file I extend it and just overload the start(...) method.
- It would be nice if I could set the ehcache.xml file from within my hibernate file. One way to do this would be to have a generic element that can contain the config file for any cache provider. For example, ehcahce might look like:
/hibernate-configuration/cache-configuration/ehcache/....
I think this would be a nice way to expose the configuration options of any cache provider but in a simple and generic way. It would be up to the hibernate cacheProvider to read in that information and pass it to the underlying cache implementation.
Let me know if you would like me to send you some code.
Regards,
Adam Greene
|