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

CacheRemoveAll

Last update:
May 18, 2026

Description

Removes all stored objects in a cache region. If no cache region is specified, objects in the default region are removed.

Returns

Nothing

History

ColdFusion 10: Added this function.

Syntax

cacheRemoveAll(region)

Properties

Parameter
Description
region
(Optional) Indicates the cache region from which to remove the stored objects. If no value is specified, default cache region is considered by default.

Example

<cfscript>
       // create cache region with no properties
       rProps={};
       CacheRegionNew("newRegion",rProps,true);
       // create cache timespan and idle time
       timeToLive = CreateTimeSpan(0, 0, 30, 0);
       timeToIdle = CreateTimeSpan(0, 0, 30, 0);
       // define objects to be inserted into cache region
       foo1=foo2=foo3={};
       // populate cache with values
       cachePut("1", "foo1", timeToLive, timeToIdle, "newRegion");
       cachePut("2", "foo2", timeToLive, timeToIdle, "newRegion");
       cachePut("3", "foo3", timeToLive, timeToIdle, "newRegion");
       WriteOutput("Before cacheRemove() :: Number of objects in the cache:" & ArrayLen(cacheGetAllIds("newRegion")));
       //clear all objects from the cache
       cacheRemoveAll("newRegion");
       WriteOutput("After cacheRemove() :: Number of objects in the cache:" & ArrayLen(cacheGetAllIds("newRegion")));
</cfscript>
Caution:
If you have created your own cache regions, remove them accordingly to avoid memory leaks.

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