I've used two methods.

1) Use a variable in the CreateTimeSpan which holds the number of minutes or hours 
that you want the cache to last.  To force the query to execute, change this variable 
to 0, hit the page, and then restore the variable back to the proper value.

2) Add the following code to application.cfm:

<CFLOCK TIMEOUT="10" THROWONTIMEOUT="Yes" TYPE="EXCLUSIVE" SCOPE="APPLICATION">
        <cfif NOT isDefined("application.cacheKiller")>
                <cfset application.cacheKiller = getTickCount()>        
        </cfif>
        <cfset request.cacheKiller = application.cacheKiller>   
</CFLOCK>

Change your queries to add this to the WHERE clause: #request.cacheKiller# = 
#request.cacheKiller#

Create a page which will assign a new value to application.cacheKiller.  Hit this page 
and then hit any page with a cached query.  They will then be reloaded until you 
change the cacheKiller variable.  The reason they reload is that the SQL has changed 
(but the result set will not change).

Craig

> -----Original Message-----
> From: Jamie Jackson [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, June 01, 2001 12:03 PM
> To:   CF-Talk
> Subject:      Best way to clear Cached Queries?
> 
> What's the best way to clear out a cached query, so that your
> production site will use the most current database information? I want
> to retain my long cache spans on a production box, but I want to be
> able to "update" or "refresh" the queries at will.
> 
> Here is my current process:
> 1. Break the connection (give the datasource a faulty path/name) in
> the administrator.
> 2. Hit the template in a browser.
> 3. Repair the broken connection in the CF administrator.
> 4. Hit the page again. The query is updated/re-cached.
> 
> I don't like this method, because it is awkward, and it momentarily
> affects the production site. Is there a better way?
> 
> Thanks,
> Jamie
> 
> 
> 
> 
> 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to