For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
CFML Reference / 

CacheRemove

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

Description

Removes an object from the cache.

Returns

Nothing.

Category

Cache functions

Function syntax

CacheRemove(Object id, boolean throwOnError, String key, boolean exact)

See also

cfcache, CacheGet, CachePut, CacheGetAllIds, CacheGetProperties, CacheGetMetadata, CacheSetProperties

History

ColdFusion 11: The ids parameter will also accept an array.

ColdFusion 10: Added the attributes 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.

key

(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

<!--- clear all object caches  --->
<cfif ArrayLen(cacheGetAllIds()) gt 0>
<cfset cacheRemove(ArrayToList(cacheGetAllIds()))>
</cfif>

<!--- create few caches --->
<cfloop from="1" to="10" index="i">
<cfset id = "cache_#i#">
<cfset timeToLive = CreateTimeSpan(0,0,30,0)>
<cfset timeToIdle = CreateTimeSpan(0,0,30,0)>
<cfset cachePut(id,createQryObj(i),timeToLive,timeToIdle)>
</cfloop>
 <cfoutput>Before cacheRemove() :: Number of objects in the cache: #ArrayLen(cacheGetAllIds())#<br></cfoutput>
             
<!--- clear all objects from the cache --->
<cfset cacheRemove("cache_1",true,"object",true)>
             
<cfoutput>(List of cache Ids - #ListSort(ArrayToList(cacheGetAllIds()),"textnocase","ASC")#)</cfoutput><br>
<cfoutput>After cacheRemove() :: Number of objects in the cache: #ArrayLen(cacheGetAllIds())#<br><br></cfoutput>
        
             
             
<!--- create an obj to put into the cache --->
<cffunction name="createQryObj" hint="create a query object to put in the cache">
<cfargument name="loopIdx" type="numeric" required="yes">
<cfset var colList = "">
<cfset var alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]>
<cfloop from="1" to="#loopIdx#" index="q">
<cfset colList = (len(colList) gt 0)? (colList & "," & "col#q#") : "col#q#">
</cfloop>
<cfset var nbrCols = listlen(colList)>
<cfset var qObj = querynew(colList)>
<cfset queryaddrow(qObj,loopIdx)>
<cfloop from="1" to="#loopIdx#" index="q">
<cfloop from="1" to="#nbrCols#" index="c">
<cfset querysetcell(qObj,"col#c#","#alphabet[randrange(1,arraylen(alphabet))]##randrange(1,1000000)#",q)>
</cfloop>    
</cfloop>
<cfreturn qObj>
</cffunction>

Example with parameter exact set to false

<!--- clear all object caches  --->
<cfif ArrayLen(cacheGetAllIds()) gt 0>
<cfset cacheRemove(ArrayToList(cacheGetAllIds()))>
</cfif>

<!--- create few caches --->
<cfloop from="1" to="10" index="i">
<cfset id = "cache_#i#">
<cfset timeToLive = CreateTimeSpan(0,0,30,0)>
<cfset timeToIdle = CreateTimeSpan(0,0,30,0)>
<cfset cachePut(id,createQryObj(i),timeToLive,timeToIdle)>
</cfloop>
 <cfoutput>Before cacheRemove() :: Number of objects in the cache: #ArrayLen(cacheGetAllIds())#<br></cfoutput>
             
<!--- clear all objects from the cache --->
<cfset cacheRemove("cache_1",true,"object",false)>
             
<cfoutput>(List of cache Ids - #ListSort(ArrayToList(cacheGetAllIds()),"textnocase","ASC")#)</cfoutput><br>
<cfoutput>After cacheRemove() :: Number of objects in the cache: #ArrayLen(cacheGetAllIds())#<br><br></cfoutput>
        
             
             
<!--- create an obj to put into the cache --->
<cffunction name="createQryObj" hint="create a query object to put in the cache">
<cfargument name="loopIdx" type="numeric" required="yes">
<cfset var colList = "">
<cfset var alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]>
<cfloop from="1" to="#loopIdx#" index="q">
<cfset colList = (len(colList) gt 0)? (colList & "," & "col#q#") : "col#q#">
</cfloop>
<cfset var nbrCols = listlen(colList)>
<cfset var qObj = querynew(colList)>
<cfset queryaddrow(qObj,loopIdx)>
<cfloop from="1" to="#loopIdx#" index="q">
<cfloop from="1" to="#nbrCols#" index="c">
<cfset querysetcell(qObj,"col#c#","#alphabet[randrange(1,arraylen(alphabet))]##randrange(1,1000000)#",q)>
</cfloop>    
</cfloop>
<cfreturn qObj>
</cffunction>

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

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices