Last active
December 20, 2015 00:09
-
-
Save awayken/6039516 to your computer and use it in GitHub Desktop.
CFML Caching Templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset local.cacheKey = hash( cgi.http_host, 'sha1' ) & '_CHANGEME'> | |
<cfset local.cacheTimespan = createtimespan( 0, 0, 10, 0 )> | |
<cfset local.cacheHTML = ""> | |
<cfcache action="get" id="#local.cacheKey#" name="local.cacheHTML"> | |
<cfif isNull( local.cacheHTML )> | |
<cfsavecontent variable="local.cacheHTML"> | |
<!--- CFML here ---> | |
</cfsavecontent> | |
<cfcache action="put" id="#local.cacheKey#" value="#local.cacheHTML#" timespan="#local.cacheTimespan#"> | |
</cfif> | |
<cfoutput>#local.cacheHTML#</cfoutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset var cacheKey = hash( cgi.http_host, 'sha1' ) & '_CHANGEME'> | |
<cfset var cacheTimespan = createtimespan( 0, 0, 10, 0 )> | |
<cfset var cacheHTML = ""> | |
<cfcache action="get" id="#cacheKey#" name="cacheHTML"> | |
<cfif isNull( cacheHTML )> | |
<cfsavecontent variable="cacheHTML"> | |
<!--- CFML here ---> | |
</cfsavecontent> | |
<cfcache action="put" id="#cacheKey#" value="#cacheHTML#" timespan="#cacheTimespan#"> | |
</cfif> | |
<cfoutput>#cacheHTML#</cfoutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
local.cacheKey = hash( cgi.http_host, 'sha1' ) & '_CHANGEME'; | |
local.cacheTimespan = createtimespan( 0, 0, 10, 0 ); | |
local.cacheObject = cacheGet( local.cacheKey ); | |
if( isNull( local.cacheObject ) ) { | |
// CFML here which creates local.cacheObject | |
cachePut( local.cacheKey, local.cacheObject, local.cacheTimespan ); | |
} | |
</cfscript> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
var cacheKey = hash( cgi.http_host, 'sha1' ) & '_CHANGEME'; | |
var cacheTimespan = createtimespan( 0, 0, 10, 0 ); | |
var cacheObject = cacheGet( cacheKey ); | |
if( isNull( cacheObject ) ) { | |
// CFML here which creates cacheObject | |
cachePut( cacheKey, cacheObject, cacheTimespan ); | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment