Description

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.

Returns

True, if the cached object exists in the specified cache region.

History

ColdFusion 10: Added this function.

Syntax

cacheIdExists(id [,_ region___])

Properties

Parameter

Description

id

(Required) The ID of the cached object.

region

(Optional) The cache region where you check for the cached object.

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

<cfscript>
       //  Create a new object 
       obj1 = {};
       obj1.name = "hello world";
       // Define the time to live and time to idle parameters 
       timeToLive=createtimespan(0,0,0,30);
       timeToIdle=createtimespan(0,0,0,30);
       writeOutput("Starting to write to cache..");
       cachePut("id_obj1",obj1,timeToLive,timeToIdle,"customcache");
       writeOutput("Done!!");
       writeOutput("Trying to check if the cached item is present...");
       writeOutput(cacheIdExists("obj1","customcache"));
</cfscript>

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