Description

Gets the metadata values for a cached object and template caches.

Returns

A 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.

Category

Cache functions

Function syntax

CacheGetMetadata(id, template [,region])

See also

cfcacheCachePutCacheGetCacheGetAllIdsCacheGetPropertiesCacheRemoveCacheSetProperties

History

ColdFusion 10: Added the parameter region

ColdFusion 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.

region

(Optional) The name of the cache region.

Example

<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#">

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy