|
DescriptionGets
the metadata values for a cached object and template caches.
ReturnsA structure
containing the cached object metadata. The structure has the following
fields:
Structure element
|
Description
|
cache_hitcount
|
The number of cache entries have been used.
|
cache_misscount
|
Number of times the object was requested,
but was not in the cache or was not up to date (was stale).
|
createdtime
|
The time when the element or object was
cached.
|
hitcount
|
Number of times the cached object has been
used.
|
idletime
|
The remaining time, in seconds, after which
the cached object is purged if it is idle.
|
lasthit
|
The time the cached object was last used,
as a date-time object, or the empty string.
|
lastupdated
|
The time the cached object was last modified,
as a date-time object, or the empty string.
|
size
|
The number of bytes the object takes up
when serialized.
|
timespan
|
The remaining time, in seconds, during which
the cached object is valid.
|
Function syntaxCacheGetMetadata(id, template)
HistoryColdFusion
9.0.1: Added the parameter template.
ColdFusion
9: Added the function.
Parameters
Parameter
|
Description
|
id
|
The ID of the cached object.
|
template
|
Gets metadata for template caches.
|
ExamplecacheTemp.cfm <cfcache action="cache" timespan="#CreateTimeSpan(0,0,10,0)#" useQueryString="true" metadata="cachemetadata">
<cfoutput>-This date/time IS cached: #Now()#-<br /></cfoutput>
</cfcache>
getMetaDataTemplate.cfm
<cfcache action="flush">
<!--- contruct the templatecacheid to pass to the getcachemetadata function --->
<cfset baseurl = "http://#cgi.server_name#:#cgi.server_port##getDirectoryFromPath(cgi.script_name)#cacheTemp.cfm">
<cfset pageid = hash(expandpath('cacheTemp.cfm'))>
<cfset lineno = 1>
<cfset templateCacheId = trim(ucase("#baseurl#_PAGEID:#pageid#_LINE:#lineno#"))>
<!--- cache the template --->
<cfhttp url="#baseurl#" />
<cfdump var="#getAllTemplateCacheIds()#"><br>
<!--- work with the returned metadata --->
<cfset templateMetaData = cachegetmetadata(templatecacheid,'Template')>
<cfdump var="#templateMetaData#">
|
|
|