cacheRemove

Removes an object from the cache.

cacheRemove(id [, throwOnError [, region[, exact]]]) → returns void

Argument Reference

id any
Required

Comma delimited list of cache IDs. A list of all available IDs can be retrieved using cacheGetAllIds. CF 11+ Can take an array instead of a list.

throwOnError boolean
Default: false

When true throws an error when cache ID does not exist.

region string

CF 10+ Specify which cache region to search

exact boolean
Default: true

CF 10+ When true, matches values in id exactly

Examples
Sample code invoking the cacheRemove function

cacheRemove( 'myCachedQuery' );

Remove using partially matching IDs

cachePut( 'cache_1', 'test data', 1000, 1000, 'test' );
cachePut( 'cache_2', 'test data', 1000, 1000, 'test' );

// this removes both cached objects:
cacheRemove( 'cache', false, 'test', false );

With exact set to true, no IDs match, so none will be deleted

cachePut( 'cache_1', 'test data', 1000, 1000, 'test' );
cachePut( 'cache_2', 'test data', 1000, 1000, 'test' );

// this removes no object:
cacheRemove( 'cache', false, 'test', true );

(ColdFusion 10 added cacheRemoveAll.)

<cfset allCacheIDs = cacheGetAllIds( ) />
<cfif not arrayIsEmpty( allCacheIDs )>
  <cfset cacheRemove( allCacheIDs ) />
</cfif>

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

Fork me on GitHub