Gets an object that is stored in the cache.
cacheGet(id [,region])
→ returns any
false
cacheGet( id [, throwWhenNotExist [, cacheName ] ] )
however it does support passing a cacheName in as the second argument for compatibility with ACF.
Puts an element in the cache and then retrieves it.
cowSays = cacheGet( "cow" );
if ( isNull( cowSays ) ) {
cowSays = "moo";
cachePut( "cow", cowSays, createTimeSpan( 0, 0, 30, 0 ), createTimeSpan( 0, 0, 15, 0 ) );
}
writeOutput( "The cow says " & cowSays );
Expected Result: The cow says moo
CF 10+ Puts an element in a named cache and then retrieves it.
cacheID = "cow";
timespan = createTimeSpan(0, 0, 30, 0);
idleTime = createTimeSpan(0, 0, 15, 0);
regionName = "region_cacheName";
cowSays = cacheGet(cacheID, regionName);
if (isNull(cowSays)) {
cowSays = "moo";
cachePut(cacheID, cowSays, timespan, idleTime, regionName);
}
writeOutput("The cow says #cowSays#.");
Expected Result: The cow says moo.
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.