Creates a new custom cache region (if no cache region exists).

cacheRegionNew(region [, properties] [, throwOnError]) → returns void

Argument Reference

region string

Name of the new cache region to be created.

properties struct

Struct that contains the cache region properties.

throwOnError boolean
Default: true

A Boolean value specifying if to throw an exception if the cache region name you specify already exists.

password string

Lucee 5+ The password for the web administrator is required to interact with Cache Connections.



DEPRECATED since version 5 Only been added for compatibility to other CFML Engines. These functions are already marked as "deprecated" and it's strongly suggested not to use them in new code.

Links more information about cacheRegionNew

Sample code invoking the cacheRegionNew function

Defining properties for the struct

<cfset defaultCacheProps = structNew()> 
 <cfset defaultCacheProps.CLEARONFLUSH = 'true'> 
 <cfset defaultCacheProps.DISKEXPIRYTHREADINTERVALSECONDS = '3600'> 
 <cfset defaultCacheProps.DISKPERSISTENT = 'false'> 
 <cfset defaultCacheProps.DISKSPOOLBUFFERSIZEMB = '30'> 
 <cfset defaultCacheProps.ETERNAL = 'false'> 
 <cfset defaultCacheProps.MAXELEMENTSINMEMORY = '5'> 
 <cfset defaultCacheProps.MAXELEMENTSONDISK = '10'> 
 <cfset defaultCacheProps.MEMORYEVICTIONPOLICY = 'LRU'> 
 <cfset defaultCacheProps.OBJECTTYPE = 'OBJECT'> 
 <cfset defaultCacheProps.OVERFLOWTODISK = 'true'> 
 <cfset defaultCacheProps.TIMETOLIVESECONDS = '5'> 
 <cfset defaultCacheProps.TIMETOIDLESECONDS = '30'> 
 <cfset cacheRegionNew('testregion',#defaultCacheProps#,false)> 
 <!--- Defining a struct object ---> 
 <cfset obj1 = structNew()> 
 <cfset = 'xyz'> 
 <cfset timeToLive = createTimespan(0,0,5,0)> 
 <cfset timeToIdle = createTimespan(0,0,10,0)> 
 <!--- Putting Cache in the USD specific cache ---> 
 <cfoutput>Starting to write to cache.</cfoutput> 
 <cfset cachePut('obj1',obj1,timetoLive,timeToIdle,'testregion')> 
 <cfoutput>Trying to fetch cached item...</cfoutput> 
 <cfset obj = cacheGet('obj1','testregion')> 

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

Fork me on GitHub