Calendar

««Nov 2009»»
SMTWTFS
1234567
89
10
11121314
15
16
17
18192021
2223
24
25262728
2930

Alert Email

Get a short email alert whenever a new entry is published.

Confidential, secure it's piece of cake to keep uptodate.

CFQUERY Enhancements

Published: 11:04 PM GMT, Friday, 17 April 2009

Among the many nice features of Open BlueDragon that fly a bit under the radar, one that has been around for quite some time that many people may not know about is the enhancements to the CFQUERY tag that exist in Open BlueDragon.

One very simple enhancement is the ability to run queries in a background thread simply by adding BACKGROUND="TRUE" to the CFQUERY tag. This allows long-running queries the results of which the user doesn't need to see immediately, for example generating a report that will be viewed later, to be run in the background and allow execution of the rest of the code in the request to continue immediately as opposed to having to wait for the query to complete.

Another nice enhancement is the ability to cache queries and give the cached version of the query a name. By adding the CACHENAME attribute to the CFQUERY tag you can cache individual queries by name, as well as flush individual queries at a later time. This gives you much more granular control over query caching. (Note that you can also use named caches with CFML/HTML content using OpenBD's CFCACHECONTENT tag.)

For example, the following code would cache a query with the name "myCachedQuery", and the cache would last indefinitely, meaning the query would be cached until flushed by you or the server is restarted.

<cfquery name="myQuery" datasource="myDSN" cachename="myCachedQuery">
...
</cfquery>

The ACTION attribute of CFQUERY allows you to flush specific queries by name:

<cfquery action="flushcache" cachename="myCachedQuery">

And you may also flush all cached queries using an action of FLUSHALL:

<cfquery action="flushall">

Queries using named caches may also still use the CACHEDWITHIN and CACHEDAFTER attributes, meaning you can give the query a name and still use timed-based cache features as well.

Just one of the many nice features available in OpenBD that people might not be aware of, so we'll blog more about these, or be sure and peruse the wiki to learn more.

Comments (0)

Add Comment