Used to find if a cached object exists in the cache region. The region can be the default cache region (either at server or application level) or the custom region you specify.

cacheIdExists(id [,_ region___]); → returns True, if the cached object exists in the specified cache region.

Argument Reference for the cacheIdExists function


Required: Yes
The ID of the cached object.


Required: No
The cache region where you check for the cached object.

Examples sample code invoking the cacheIdExists function

Tag Syntax

Checks if the cache object is present in the user-defined cache region

<!--- Creating a new object ---> 
 <cfset obj1 = structNew()> 
 <cfset = 'xyz'> 
 <!--- Defining the time to live and time to Idle parameters ---> 
 <cfset timeToLive=createTimespan(0,0,0,30)> 
 <cfset timeToIdle=createTimespan(0,0,0,30)> 
 <cfoutput>Starting to write to cache..</cfoutput> 
 <cfset cachePut('obj1',obj1,timeToLive,timeToIdle,'customcache')> 
 <cfoutput>Trying to check if the cached item is present...</cfoutput> 

Tag Syntax

Checks if the cache object is present in the default cache region

<cfset obj2 = structNew()> 
 <cfset = 'xyz'> 
 <cfoutput>Starting to write to cache..</cfoutput> 
 <cfset cachePut('obj2',obj2)> 
 <cfoutput>Trying to fetch cached item...</cfoutput> 
 <cfset obj = cacheGet('obj2')> 

Fork me on GitHub