By adding a certain functionality to the tag <cfcache> it would largely gain importance for programmers. We thought about adding a closing tag to the <cfcache> tag and cache everything between the opening and closing tag until the timeout has occured. Let us take the following example:
<cfcache action="CONTENT" timespan="#createTimeSpan(...)#" key="#xfa.action#">
<cfquery name="getHeader" datasource="db">
Select headerImage from headers where headerID = #url.headerID#
</cfquery>
...
some code
...
<cfoutput><img src="#getHeader.headerImage#"></cfoutput>
</cfcache>
The attribute key is necessary to add a certain individuality for programmers. So you can add your own custom keys in order to specify the cache in more details.
Within the next 60 seconds the content of the tag will be read its data from cache and display it if:
- cgi.script_name and cgi.query_params are the same
- the attribute key contains the same value
4 responses so far ↓
1 Alan Williamson // Mar 29, 2007 at 11:02 AM
We also allow you to group your caches, allowing you to quickly flush groups or individual cached items.
We didn't override the <cfcache> as this causes confusion with the current implementation. Two completely different caching techniques.
2 Streit // Mar 29, 2007 at 12:08 PM
<cfcache action="content" timespan="#...#" key="#xfa.action#">
<cfquery name="getHeader" datasource="db">
Select headerImage from headers where headerID = #url.headerID#
</cfquery>
...
some code
...
<cfoutput><img src="#getHeader.headerImage#"></cfoutput>
</cfcache>
first if you want to use as cache only for a part of the page, you have to set the attribute "action" to "content", the you still use the attribute "timespan" to define the timepan for the cache, then at last the attribute "key" is optional.
3 Streit // Mar 29, 2007 at 12:46 PM
i does not know this tag (cfcachecontent) and i have also not found any docu for it.
you write "We didn't override the <cfcache> as this causes confusion with the current implementation. Two completely different caching techniques."
But both are caching mechanisms, when i follow your meaning, you should also have a tag like "cffileUpload" or "cffileWrite" insteat of "cffile", because this are 2 completly different file manipulation techniques. for that we have the attribute "action" to control this. in the case of the tag "cfcache" you have to use the action "content" (alias "contentcache").
you still can use the tag "cfcache" the same way as in Neo, but if you use it with attribute action="content", you dont have to learn a completly new tag, because you can use most attributes in the same way.
then you write "allowing you to persist to directory or database", one of the biggest feature of railo 1.1 are the resources, you can not only invoke the local filesystem with tags like [cffile, cfdirectory, cache ...] or in functions like [fileExists ...], you always have the possibility to use all resources defined for your enviroment (you can also extends your own).
Example:
<cfcache ... directory="ram://this/store/in/Memeory">
<cfcache ... directory="d:/this/store/local">
(or <cfcache ... directory="file://d:/this/store/local">)
<cfcache ... directory="zip://d:/my/zip/file.zip!/cache">
<cfcache ... directory="ftp://www.railo.ch/remote/ftp/directory">
<cfcache ... directory="datasource://mydatasource/to/db/">
...
in railo 1.1 you not only can use database or directory as a cache pool, you can also use a many more.
4 Fred B // Sep 19, 2007 at 1:15 PM
Leave a Comment