Whatever message this page gives is out now! Go check it out!

CacheRemove

Last update:
May 18, 2026

Description

Removes one or more objects from the cache.

Returns

Nothing.

Category

Function syntax

CacheRemove(id, [boolean throwOnError, String region, boolean exact])

See also

cfcacheCacheGetCachePutCacheGetAllIds, CacheGetProperties, CacheGetMetadata, CacheSetProperties

History

ColdFusion (2018 release): Renamed the parameter key to region.
ColdFusion 11: The ids parameter will also accept an array.
ColdFusion 10: Added the parameters region and {{exact}}.
ColdFusion 9: Added the function.

Parameters

Parameter
Description
id
A comma delimited string of IDs of the cached objects to remove. Starting from ColdFusion 11, you can also specify an array of IDs.
throwOnError
(Optional) A Boolean value specifying whether to throw an exception if any ID does not specify a cached element. The default value is false.
region
(Optional) Name of the cache region from which to remove the cached objects.
exact
(Optional) If true, the search narrows down to values that exactly match the IDs (for removal). The default value is true.

Example with parameter exact set to true

<cfscript>
       // get all cache ids of cache region, myRegion
       Writedump(cacheGetAllIds("myRegion",true));
       //array of all cache ids are below:
             //     CACHE_1
             //     CACHE_3
             //     CACHE_2
       // when exact=true, does not remove any objects, as no ids match
       CacheRemove("cache",true,"myRegion",true);
       Writeoutput("All cache ids are");
       try{
             Writedump(cacheGetAllIds("myRegion"));
       }
       catch(any e){
             WriteOutput("Error: " & e.message);
       }
</cfscript>
Example with parameter exact set to false
<cfscript>
       // get all cache ids of cache region, myRegion
       Writedump(cacheGetAllIds ("myRegion",true));
       //array of all cache ids are below:
             //     CACHE_1
             //     CACHE_3
             //     CACHE_2
       // when exact=false, removes all objects with partially matching ids
       CacheRemove("cache",true,"myRegion",false);
       Writeoutput("All cache ids are");
       Writedump(cacheGetAllIds ("myRegion"));
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page