Results 1 to 3 of 3

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

  1. #1
    Join Date
    Jan 2012
    Posts
    16

    Default 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. #2
    Join Date
    Oct 2012
    Location
    Shenzhen, China
    Posts
    13

    Default

    JMX probably worths a try.

  3. #3
    Join Date
    Nov 2012
    Posts
    1

    Default

    I tried JMX but doesn't worked well enough. Elaborate if possible.
    Request no obligation car shipping quotes now !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •