Announcement Announcement Module
Collapse
No announcement yet.
How can I switch among caching mechanisms at run time using Spring cache? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I switch among caching mechanisms at run time using Spring cache?

    Hi there,

    I understand that I can set up spring such that I can use either a ConcurrentMap cache, or ehcache cache by swapping between these two configurations, like:
    Code:
    <bean id="cacheManager"
        class="org.springframework.cache.ehcache.EhCacheCacheManager"
        p:cacheManager-ref="ehcache"/>
    ...
    <bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
        p:configLocation="ehcache.xml"
        p:shared="true"/>
    or
    Code:
    <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
      <property name="caches">
     <set>
       <bean
                 class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
                 p:name="employee"/>
     </set>
      </property>
    </bean>
    but since the cacheManager is unique, if I want to include both of them in the configuration, I need to specify them in different profiles with names like: "concurrentManager", "ecacheManager", is there a way for me to switch between them at run time?
    Thanks,

    David

  • #2
    JMX probably worths a try.

    Comment


    • #3
      I tried JMX but doesn't worked well enough. Elaborate if possible.

      Comment

      Working...
      X