Caching Query Results  
 
 

The ability to save query result sets in server memory is a significant performance enhancement for all ColdFusion sites, especially those supporting a high volume of repetitive data access.

To call cached query data, the new query must match exactly any of the following values that it uses: have the same data source, query name, DBTYPE, SQL statement, user name, and password as the cached data set. If you are using native drivers, the query syntax must also match the DBSERVER and DBNAME (Sybase only) values.

Two CFQUERY attributes control the cache implementation:

  • CFCACHEDAFTER -- Sets a date to check before running a new query
  • CFCACHEDWITHIN -- Sets a time range to check using the CreateTimeSpan function

The cache is self-regulating once the maximum number of stored queries is set. That is, when the limit is reached, the oldest result set is replaced by the current one.You set the appropriate number of queries to cache on the ColdFusion Administrator Server Settings page.

In setting the optimal cache value, consider such factors as available system resources and the time required to process complex queries versus storing the result sets in memory.

The decision point for enabling the cache and for choosing which attribute to set is the level of tolerance you (and your users) have for the timeliness of query results. For important record sets that are frequently updated, a short time interval is recommended for maintaining the cache. Generally, the more static the record set, the greater the time interval that can be safely set.



 
 
BackUp LevelNext
 
 

allaire     AllaireDoc@allaire.com
    Copyright © 1998, Allaire Corporation. All rights reserved.