-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Query cache lifetime
PostPosted: Tue Jun 16, 2009 4:22 am 
Newbie

Joined: Tue Jun 16, 2009 4:20 am
Posts: 2
Hi,

I am using JPA/Hibernate and am trying to set up the cache. How long will a cached query be cached? Can I set the lifetime in the cache?

Thanks
Markus


Top
 Profile  
 
 Post subject: Re: Query cache lifetime
PostPosted: Tue Jun 16, 2009 4:53 am 
Beginner
Beginner

Joined: Wed Dec 10, 2008 5:59 am
Posts: 47
Hi,

As far as i've understood, a query cache will expire whenever you change something in the table(s) that your cached query depends on.
Furthermore, you can configure the query cache in your ehcache.xml (if that is the cache provider your'e using):

Code:
    <cache
        name="org.hibernate.cache.StandardQueryCache"
        maxElementsInMemory="2500"
        eternal="false"
        timeToLiveSeconds="900"
        overflowToDisk="false"
    />


Top
 Profile  
 
 Post subject: Re: Query cache lifetime
PostPosted: Wed Jun 17, 2009 4:46 am 
Newbie

Joined: Tue Jun 16, 2009 4:20 am
Posts: 2
sbrattla wrote:
Hi,

As far as i've understood, a query cache will expire whenever you change something in the table(s) that your cached query depends on.
Furthermore, you can configure the query cache in your ehcache.xml (if that is the cache provider your'e using):

Code:
    <cache
        name="org.hibernate.cache.StandardQueryCache"
        maxElementsInMemory="2500"
        eternal="false"
        timeToLiveSeconds="900"
        overflowToDisk="false"
    />



How would Hibernate know that something has changed in the underlying tables if it is using that cache? I have set the default cache to this and activated the 2nd level cache:

Code:
    <defaultCache
            maxElementsInMemory="5000"
            eternal="false"
            timeToLiveSeconds="15"
            overflowToDisk="false"
            diskPersistent="false"
            memoryStoreEvictionPolicy="LFU"
            >


However, if I change something in the table, it is not reflected in the entities. Here are the settings in persistence.xml:
Code:
          <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider"/>
            <property name="hibernate.cache.use_second_level_cache" value="true"/>
            <property name="hibernate.cache.use_query_cache" value="false"/>
            <property name="hibernate.generate_statistics" value="true"/>
            <property name="hibernate.cache.provider_configuration_file_resource_path" value="ehcache.xml"/>


Why isn't the cached cleared?

Thanks
Markus


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.