Lets you retrieve the underlying cache object to access additional cache functionality that is not implemented in the tag cfcache .
Note: CautionUsing the cacheGetSession function might pose security vulnerabilities. If you wish to disable the usage of this function, add it to Sandbox Security. For more information, see Using sandbox security. |
The underlying cache object.
cacheGetSession(objectType,[isKey])
Parameter |
Description |
|---|---|
objectType |
Any of the following values:
|
isKey |
(Optional) Set to true if objectType is user-defined cache. The default value is false. |
cfcache , CachePut, CacheGet, CacheGetAllIds, CacheGetMetadata, CacheRemove, CacheSetProperties
ColdFusion 9.0.1: Added this function
The following example shows how to create a user-defined cache by adding an entry in ehCache .xml:
<cache name="customcache" maxElementsInMemory="1000" eternal="false" timeToIdleSeconds="720" timeToLiveSeconds="720" overflowToDisk="true" diskSpoolBufferSizeMB="10" maxElementsOnDisk="100000" diskPersistent="true" diskExpiryThreadIntervalSeconds="3600" memoryStoreEvictionPolicy="LRU"/>
After you specify the details in the ehCache.xml, you can use the user-defined cache as shown here:
<!--- put an object into user-defined object cache --->
<cfset cachePut("cache1","hello",15,15,customCache)>
<!--- get underlying user-defined object cache --->
<cfset objectCache = cachegetsession(customCache,true)>
<!--- get/print user-defined object cache properties --->
<cfset config = objectCache.getCacheConfiguration()>
<cfoutput>
getMaxElementsInMemory() :: #config.getMaxElementsInMemory()#<br>
isEternal() :: #config.isEternal()#<br>
getTimeToIdleSeconds() :: #config.getTimeToIdleSeconds()#<br>
getTimeToLiveSeconds() :: #config.getTimeToLiveSeconds()#<br>
isOverflowToDisk() :: #config.isOverflowToDisk()#<br>
getDiskSpoolBufferSizeMB() :: #config.getDiskSpoolBufferSizeMB()#<br>
getMaxElementsOnDisk() :: #config.getMaxElementsOnDisk()#<br>
isDiskPersistent() :: #config.isDiskPersistent()#<br>
getDiskExpiryThreadIntervalSeconds() :: #config.getDiskExpiryThreadIntervalSeconds()#<br>
getMemoryStoreEvictionPolicy() :: #config.getMemoryStoreEvictionPolicy()#<br>
isClearOnFlush() :: #config.isClearOnFlush()#<br>
</cfoutput>
Example 2
The following example shows how to use the function cacheGetSession to operate on default caches:
<!--- put an object into user-defined object cache --->
<cfset cachePut("cache1","hello",15,15)>
<!--- get underlying user-defined object cache --->
<cfset objectCache = cachegetsession("object",true)>
<!--- get/print user-defined object cache properties --->
<cfset config = objectCache.getCacheConfiguration()>
Sign in to your account