Kevin,

If your users will be using different criteria, they will not be using the
cached query.  CF actually caches the SQL statement.  Only if your users
enter the exact search criteria will they get the cached query back, but
that's what you want to happen.

These two statements, even though the queries are named differently will be
cached.  Once "test1" is run, "test2" will not hit the db.

<cfquery datasource="whatever" name="test1"
cachedwithin="#createTimeSpan(0,0,5,0)#>
        select * from myTable
</cfquery>

<cfquery datasource="whatever" name="test2"
cachedwithin="#createTimeSpan(0,0,5,0)#>
        select * from myTable
</cfquery>

These two statements will cause to hits to the database even though they are
named the same thing

<cfquery datasource="whatever" name="test1"
cachedwithin="#createTimeSpan(0,0,5,0)#>
        select * from myTable where id = 1   <---- Database hit
</cfquery>

<cfquery datasource="whatever" name="test1"
cachedwithin="#createTimeSpan(0,0,5,0)#>
        select * from myTable where id = 2       <---- Database hit
</cfquery>

<cfquery datasource="whatever" name="test1"
cachedwithin="#createTimeSpan(0,0,5,0)#>
        select * from myTable where id = 1   <---- Cache hit on first query
</cfquery>

HTH

Marlon


-----Original Message-----
From: Kevin Bridges [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 9:41 AM
To: Fusebox
Subject: Query Caching


What is the best way to cache queries in the following scenario?  I have a
search screen that posts to a frameset in which there are 4 frames that all
use different parts of the query.  Behaviors are defined that let a
scrolling action in one frame control scrolling in other frames so the data
has to synch ... meaning the same query must be used for all 4 frames.
Because it is a search interface multiple users may be entering different
criteria for the search in rapid succession.

>From my understanding if I just cache the query for a set time period it
becomes cached for all users ... So I was thinking of adding the cftoken to
the end of the query name and setting the time period really low ... but if
I set time period to low and user is on a slow connection I run the risk of
not having the query available to all 4 frames because they won't load in
time.  If I set the time period to high then the user will not get new
information if the search returns no results and they decide to conduct
another search or they simply conduct a new search.

I read a suggestion of checking for an attributes flag to refresh the query
..... but the only way to refresh a cached query (please correct me if wrong)
is to generate a completely new query of same name with no cachedwithin
information ... If I do that then the 4 frames break because query is not
persistent.

Any suggestions or ideas?

Thanks,

Kevin Bridges
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to