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.
Nothing
CacheSetProperties(propStruct, [region])
cfcache, CacheGet, CachePut, CacheGetAllIds, CacheGetProperties, CacheGetMetadata, CacheRemove
ColdFusion 10: Added the parameter region.
ColdFusion 9: Added the function.
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:
|
objectType
|
Object | The type of cache: one of the following:
|
overflowToDisk |
False | A 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. |
maxelementsinmemory property name is renamed to maxentrieslocalheap. The reason for this change is that Ehcache has deprecated maxelementsinmemory.
<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";
// 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>
Sign in to your account