Removes all stored objects in a cache region. If no cache region is specified, objects in the default region are removed.
Nothing
ColdFusion 10: Added this function.
cacheRemoveAll(region)
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. |
<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>
If you have created your own cache regions, remove them accordingly to avoid memory leaks.
Sign in to your account