I have a services project and a web project. I need to have eh-cache in both projects.
The idea is that if the service project is updated, it's cache-related changes (like keys and invalidation rules) will also be available, while no changes are made to the web project. Being so independent, the service project can also be used with another projects without them even knowing of eh-cache.
At this point, my web project also uses eh-cache for its own purposes. I am not much experienced with eh-cache and I fear that the two projects might clash when deployed together. I also did not find relevant information on eh-cache site.
Can you provide me some information how to best configure the two projects, so that I can achieve the above requirements?
Edit:
I am using Spring, therefore I will prefer to use it for my cache managers.
I am using the following in the context.xml for each jar with ehcache, for instance for
jar 1 I have:
<ehcache:annotation-driven cache-manager="ehCacheManager1" />
<bean id="ehCacheManager1" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache-1.xml" />
</bean>
and for jar 2 I have
<ehcache:annotation-driven cache-manager="ehCacheManager2" />
<bean id="ehCacheManager2" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache-2.xml" />
</bean>
So, will both caches be up and working? I fear the ehcache:annotation-driven
will get overridden by the last read context and only one cache will be operational. Am I wrong, or missing something?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…