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

CacheSetProperties

Last update:
May 18, 2026

Description

Sets the cache properties for the object cache, the page cache, or both. If a cache does not yet exist, creates it. The cache and properties are application-specific.

Returns

Nothing

Category

Function syntax

CacheSetProperties(propStruct, [region])

See also

cfcacheCacheGetCachePutCacheGetAllIds, CacheGetProperties, CacheGetMetadata, CacheRemove

History

ColdFusion 10: Added the parameter region.
ColdFusion 9: Added the function.

Parameters

Parameter
Description
propsStruct
A structure specifying the cache properties plus identifying information
region
(Optional) The name of the cache region
The propsStruct structure can have any or all of the following fields:
Structure element
Default
Description
diskPersistent
False
A Boolean value specifying whether to persist caches stored on disk through JVM restarts.
diskStore
 
The disk store. The disk store provides a spooling facility that can be used for additional storage during cache operation. The disk store can also be used for cache persistence.
If one or more caches requires a disk store, but there isn't any disk store configured, a default directory is used.
To disable creation of a disk store path, comment out the diskStore element in ehcache.xml, located in <ColdFusion home>/cfusion/lib.
<diskStore path="java.io.tmpdir"/>
eternal
False
A Boolean value specifying whether no timeout or  idletime  applies. A true value indicates that the object or page is cached without any timespan being specified.
maxElementsOnDisk
10000000
The maximum number of objects that can be stored on disk if  overfllowtodisk  is true.
maxEntriesLocalHeap
 
The maximum number of objects that can be cached in memory. If the number is exceeded and  overflowtodisk  is false, the new objects entered replace old elements using algorithm specified in the memoryevictionpolicy entry.
memoryEvictionPolicy
LRU
The algorithm used to evict old entries when the maximum limit is reached. The algorithms used are:
  • LRU (Least Recently Used)
  • LFU (Least Frequently Used)
objectType
Object
The type of cache: one of the following:
  • template - Set properties for the page cache, which contains cached pages and page segments.
  • object - Set properties for the object cache.
  • all - Set properties for both cache types.
overflowToDisk
FalseA Boolean value specifying whether when the maximum number of elements allowed in memory is reached, objects can be moved to disk, as determined by the  memoryevictionpolicy  value.
statistics
True
true indicates that statistics collection for Ehcache is enabled.
timeToIdleSeconds
86400
The idle time in seconds. Used if a cfcache tag does not specify an idleTime attribute.
timeToLiveSeconds
86400
The timeout time in seconds. Used if a  cfcache  tag does not specify a timespan attribute.
Note:
maxelementsinmemory property name is renamed to maxentrieslocalheap. The reason for this change is that Ehcache has deprecated maxelementsinmemory.

Example

<cfscript>
 myProps = StructNew();
 myProps.diskStore = "/Users/user1";
 myProps.diskPersistent = true
 myProps.eternal = false
 myProps.maxElementsInMemory = "5000";
 myProps.maxElementsOnDisk = "100000";
 myProps.memoryEvictionPolicy = "LRU";
 myProps.objectType = "Object";
 myProps.overflowToDisk = "true";
 myProps.timeToIdleSeconds = "86400";
 myProps.timeToLiveSecond = "86400";
 myProps.maxEntriesLocalHeap="20";
 // remove cache region
 CacheRegionRemove("myCacheRegion_1")
 // create a cache region with struct myProps
 CacheRegionNew("myCacheRegion_1",myProps,true)
 // set properties for the cache
 CacheSetProperties(myProps,"myCacheRegion_1")
 writeDump(cacheGetProperties("myCacheRegion_1"));
</cfscript>

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