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 boolean

Argument Reference

id string

The ID of the cached object.

region string

The cache region where you check for the cached object.

Sample code invoking the cacheIdExists function

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> 

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')> 

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub