Saturday, March 01, 2003

CodeBit; How Do I Clear a CachedWithin Query Using ColdFusion?

If you use a dynamic timespan instead of a fixed timespan, you can clear the cache by setting the timespan to zero when the query is executed.

<cfif url.clear_cache eq 1>
    <cfset time_span = CreateTimeSpan(0,0,0,0)>
<cfelse>
    <cfset time_span = CreateTimeSpan(0,0,30,0)>
</cfif>

<cfquery ... cachedwithin="#time_span#">
   ... do some sql here.
</cfquery>
Post a Comment