Announcement Announcement Module
Collapse
No announcement yet.
Ehcache refreshed at request time Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ehcache refreshed at request time

    Hi,


    I have my EhCache being refreshed each 24 hrs as you can see in the snippet below:

    <ehcache>
    <!-- Required elements -->
    <diskStore path="/MQ/programs/xxx/"/>
    <defaultCache
    maxElementsInMemory="10000"
    eternal="false"
    timeToIdleSeconds="86400"
    timeToLiveSeconds="86400"
    overflowToDisk="true"/>
    </ehcache>



    I wonder if there's a way to mandate to EhCache that it has to refresh the cache in a given moment, I mean, consider I have a web page with a button that says "Refresh Cache Now" so the cache does not have to wait 24 hrs after the last update.

    Thanks!

  • #2
    I would guess you want to call clear.
    http://ehcache.sourceforge.net/apido...tml#clearAll()
    http://www.springframework.org/docs/...ctoryBean.html
    Last edited by karldmoore; Aug 29th, 2007, 11:26 AM.

    Comment


    • #3
      Thanks for your replay, however considering I have my cache configured in the way described below, How could I get a reference to the EhCache interface?

      <bean id="mySessionFactory"
      class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
      <property name="dataSource" ref="myDataSource" />
      <property name="mappingResources">
      <list>
      <value>resources/hibernate/Agents.hbm.xml</value>
      <value>resources/hibernate/CAgents.hbm.xml</value>
      <value>resources/hibernate/Passes.hbm.xml</value>
      <value>resources/hibernate/VersionsForm.hbm.xml</value>
      <value>resources/hibernate/Aut.hbm.xml</value>
      <value>resources/hibernate/MsgMgr.hbm.xml</value>
      <value>resources/hibernate/IntAut.hbm.xml</value>
      <value>resources/hibernate/ExpInt.hbm.xml</value>
      </list>
      </property>
      <property name="hibernateProperties">
      <props>
      <prop key="hibernate.dialect">org.hibernate.dialect.Orac le9Dialect</prop>
      <prop key="hibernate.cache.provider_class"> org.hibernate.cache.EhCacheProvider</prop>
      <prop key="hibernate.cache.use_query_cache">true</prop>
      <prop key="hibernate.cache.provider_configuration_file_r esource_path">resources/Ehcache.xml</prop>
      </props>
      </property>
      </bean>

      Comment


      • #4
        Ahhh I see your problem. I'm not sure if you can get at the cache or not, I'd have a look at the JavaDoc.
        Last edited by karldmoore; Aug 29th, 2007, 11:26 AM.

        Comment


        • #5
          You can get it through the Hibernate API :

          http://www.hibernate.org/hib_docs/v3...e/EhCache.html

          Otherwise I suppose you can get it with the ehcache API, but since ecache 1.2 the ehcache manager isn't a singleton anymore, so you have to know its instance name (and I have no idea what this name is...) :

          http://ehcache.sourceforge.net/samples.html

          Comment


          • #6
            Is there an example where Spring + Hibernate + EhCache + a chance to manipulate the cache through a config file and/or direct cache refresh somewhere? Thanks!

            Comment


            • #7
              I'm sure there's a bug in JIRA about injecting in the Hibernate cache through LocalSessionFactoryBean. There might have even been a patch attached to it. This would make the whole thing a lot easier.
              Last edited by karldmoore; Aug 29th, 2007, 11:26 AM.

              Comment

              Working...
              X