Results 1 to 7 of 7

Thread: Ehcache refreshed at request time

  1. #1

    Default 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. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    Last edited by karldmoore; Aug 29th, 2007 at 11:26 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  3. #3

    Default

    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>

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    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 at 11:26 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  5. #5

    Default

    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

  6. #6

    Default

    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!

  7. #7
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    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 at 11:26 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

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