Stores an object in the cache.
cachePut(id, value [, timespan] [, idleTime] [, region] [, throwOnError])
→ returns void
false
<cfset cachedData = cacheGet("wt-6-cache")>
<!--- If the data is not cached, create it and do a cache put. --->
<cfif isNull(cachedData)>
Cache doesn't exist, so create it.<br />
<cfset sleep(1000)>
<cfset cachedData = "This date/time IS cached: #now()#<br />">
<cfoutput>#cachedData#</cfoutput>
<cfset cachePut("wt-6-cache", cachedData, createTimespan(0,0,0,10))>
</cfif>
I place data into the default cache.
// generate some data to cache
data = { bar = 'foo', foo = 'bar' };
// add the data to a named cache
cachePut( 'cached_object_name_or_id', data, createTimeSpan( 0, 0, 30, 0 ), createTimeSpan( 0, 0, 15, 0 ) );
I place data into a named cache. CF 10+ Lucee 4.5+
// generate some data to cache
data = { bar = 'foo', foo = 'bar' };
// add the data to a named cache
cachePut( 'cached_object_name_or_id', data, createTimeSpan( 0, 0, 30, 0 ), createTimeSpan( 0, 0, 15, 0 ), 'region_cacheName' );
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.