Using cachedwithin attibute inside cfquery

When you use the cachedwithin attribute in cfquery, how does it store the request in memory. Does it only save its name, which you assign to the query? For example, if on my index page I cache the request for an hour and the name getPeople there is a request with the same name on another page (or on the same page, for that matter), use cached results or use some better logic to decide whether Is it the same request?

Also, if there is a variable in your request, does the cache take into account the value of the variable?

+5
source share
2 answers

This is not only a name - it is the exact query that you use.

<cfquery name="getPeople" cachedwithin=".5" ...>
select name from employee order by name
</cfquery>

, , . :

<!--- Different name, same SQL: A new cached query --->
<cfquery name="getEmployees" cachedwithin=".5" ...>
select name from employee order by name
</cfquery>

<!--- Different SQL, same name: Redefining the cached query --->
<!--- Note: As pointed out in comments, it not really overwriting the old query
      of the same name, but making a new one in the cache. The first one by the
      same name is still in the cache, waiting for eviction. --->
<cfquery name="getPeople" cachedwithin=".5" ...>
select name from employee order by name desc
</cfquery>

, . cfqueryparam - - , cachedwithin, . , , cachedwithin , , .

+5

All Articles