-->
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.  [ 1 post ] 
Author Message
 Post subject: "Selective" query caching?
PostPosted: Fri Mar 24, 2006 11:55 pm 
Newbie

Joined: Fri Mar 24, 2006 11:28 pm
Posts: 1
Hi,

I've looked around in forums and the HIA book without luck. I'm wondering if it is possible to only cache a query given a set of conditions, for example, only if the result set is not empty. What I would expect HB to do would be to:

for a given a query Q:
lookup Q's result set in cache region
if result set exists, return that result set
otherwise, run Q and get result set
ONLY cache result set if certain condition applies (eg result set not empty)

The "not empty" case would be very handy for a "find or create" method that runs (expensive) Q to find an instance of a mapped class C. if the instance is not found, the method inserts a new instance of C. I would like HB to cache Q only if an instance of C was found. Otherwise, the 2nd time "find or create" is run, if the cached (empty) result set is used, the method will incorrectly try to insert a new instance of C...

For this example, I do understand that the default query cache factory would nuke every cached query that depends on C after the insert (including the cached result for Q when it found no results), but in my particular app, I've extended the default query cache factory to be "stale tolerant", so that cached queries are still used within a configurable amount of time after they've been deemed stale...


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

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.