Well, you can't dynamically "name" queries, but remember that query
caching requires the EXACT same SQL to be used.

So if you do this:

<cfquery name="qGetSite" cachedwithin...>
SELECT sitename 
FROM tblSites
WHERE siteID=#session.siteID#
</cfquery>

Then you'll cache each query using a different siteid.  This is done at
the SQL level (that exact sql will be cached and returned) - the name of
the query used in CF has nothing to do with it at all.

In other words each and every siteID used with this will cache a NEW AND
SEPARATE query, even if they'll all named "qGetSite".

Lastly, considering that this is based on the SQL level you could create
"custom" cached queries by including custom SQL.

For example the following (should) create separate cached queries for
each user (assume that "#UserID# is some sort of unique ID, perhaps the
session ID):

<cfquery name="qGetSite" cachedwithin...>
SELECT sitename, '#UserID#' AS UserID
FROM tblSites
WHERE siteID = 1
</cfquery>

Even tho' the queries will all return the same data (if the DB doesn't
change) they will all be cached separately since the SQL itself has
changed.

This isn't all that useful of a trick since the SQL call itself is
usually "personalized" without adding the extra column, but it may be
useful for a highly dynamic environment where everybody wants "current
data" but are happy using that current data for a while.

But still, I've never found a place where I needed to do that.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to