Permission denied Params Cache

Params Cache

if( NOT StructKeyExists(request,'params') ) request.params = StructNew(); if( NOT StructKeyExists(request.params,'Action') ) request.params.action = 'RebuildIfHit'; if( NOT StructKeyExists(request.params,'rebuildMinutesBeforeExpire') ) request.params.rebuildMinutesBeforeExpire = 1; // 1 minute if( NOT StructKeyExists(request.params,'rebuildTimeout') ) request.params.rebuildTimeout = 30; // 30 seconds if( NOT StructKeyExists(request.params,'MaxUnusedMinutes') ) request.params.MaxUnusedMinutes = 480; // 8 hours WriteOutput('

Action: #request.params.action#'); WriteOutput('
Rebuild Minutes Before Expire: #request.params.rebuildMinutesBeforeExpire#'); WriteOutput('
Rebuild Timeout: #request.params.rebuildTimeout#'); WriteOutput('
Max Unused Minutes: #request.params.MaxUnusedMinutes#


'); LogIt( "Param Cache Rebuild Job ran. Parameters: Action:[#request.params.action#] RebuildMinutesBeforeExpire:[#request.params.rebuildMinutesBeforeExpire#] RebuildTimeout:[#request.params.rebuildTimeout#] MaxUnusedMinutes:[#request.params.MaxUnusedMinutes#]" );
types = StructKeyList(application.CS_PageParamCache); type = ListGetAt(types,t); // If custom element, query to figure out when the last time the element was updated. // If not updated after cache was written, cache is still good and can be extended // For non-custom elements make update date now to force cache rebuild if about to expire. elementLastUpdated = now(); if( FindNoCase('custom:', type ) ) { elementTypeID = getElementIDGivenName(type); if( elementTypeID ) elementLastUpdated = getElementTypeLastUpdate(elementTypeID); } WriteOutput('

#type# (Last Updated:#dtf(elementLastUpdated)#)

'); // get list of element instances elements = StructKeyList(application.CS_PageParamCache[type]);
element = ListGetAt(elements,i); caches = StructKeyList(application.CS_PageParamCache[type][element]); PageID = ListFirst( element, "_" ); ControlID = ListLast( element, "_" ); page_url = getPageURL( PageID ); WriteOutput('
#Page_URL# #ControlID# [Clear All]
');
WriteOutput('
'); WriteOutput('
Time
'); WriteOutput('
Cache Name
'); WriteOutput('
Created
'); WriteOutput('
Last Use
'); WriteOutput('
Rebuild Time
'); WriteOutput('
Expires
'); WriteOutput('
Secs
'); WriteOutput('
Hit Count
'); WriteOutput('
Status
'); WriteOutput('
Actions
'); WriteOutput('
');
cache = ListGetAt( caches, j ); if( StructKeyExists(application.CS_PageParamCache[type][element], cache) ) { expires = application.CS_PageParamCache[type][element][cache].expires; rebuildTime = DateAdd('n', -request.params.rebuildMinutesBeforeExpire, expires); secBeforeRebuild = DateDiff( 's', now(), rebuildTime ); hitCount = application.CS_PageParamCache[type][element][cache].hitCount; created = application.CS_PageParamCache[type][element][cache].created; lastuse = application.CS_PageParamCache[type][element][cache].lastuse; if( DateCompare( elementLastUpdated, created ) eq 1 ) status = 'Stale'; else status = 'Valid'; if( DateCompare( now(), expires ) eq 1 ) status = 'EXPIRED'; else if( secBeforeRebuild lt 0 AND (request.params.action eq 'RebuildAlways' OR (request.params.action eq 'RebuildIfHit' AND hitCount gt 0) ) ) status = 'REBUILDING'; relativeurl = page_url & "?forceRender=1" & cache; fullurl = CGI.http_host & page_url & "?forceRender=1" & cache; WriteOutput('
'); WriteOutput('
#TimeFormat(now(),"HH:mm:ss")#
'); WriteOutput('
#dispCacheName(cache)#
'); WriteOutput('
#dtf(created)#
'); WriteOutput('
#dtf(lastuse)#
'); WriteOutput('
#dtf(rebuildTime)#
'); WriteOutput('
#dtf(expires)#
'); WriteOutput('
#secBeforeRebuild#
'); WriteOutput('
#hitCount#
'); WriteOutput('
#status#
'); if( status eq 'REBUILDING' ) WriteOutput('
 
'); else WriteOutput(''); WriteOutput('
'); }
// cache is about to expire if( DateCompare( now(), rebuildTime ) eq 1 AND DateCompare( now(), expires ) eq -1 ) { if( DateCompare( elementLastUpdated, created ) neq 1 ) { // element has NOT been updated since cache was created. Cache is still good. Extend the expiration date. application.CS_PageParamCache[type][element][cache].expires = DateAdd( 'n', application.CS_PageParamCache[type][element][cache].minutesToCache, expires ); WriteOutput('
Element not updated. Extending cache to #dtf(application.CS_PageParamCache[type][element][cache].expires)#
'); LogIt( "Element Type not updated since #dtf(elementLastUpdated)#. Extending cache '#cache#' to #dtf(application.CS_PageParamCache[type][element][cache].expires)#" ); } else if( request.params.action eq 'RebuildAlways' OR (request.params.action eq 'RebuildIfHit' AND hitCount gt 0) ) { // The element was updated since the cache was built. Invoke the page to rebuild. status = requestPage( fullurl, request.params.rebuildTimeout ); WriteOutput('
Rebuilt #fullURL# #status#
'); } } // cache is expired else if( DateCompare( now(), expires ) eq 1 ) { // Rebuild - for some reason we did not get to it if( request.params.action eq 'RebuildAlways' OR (request.params.action eq 'RebuildIfHit' AND hitCount gt 0) ) { // only try rebuilding if expired with the limit specified in reverse if( DateCompare( now(), DateAdd( 'n', request.params.rebuildMinutesBeforeExpire, expires) ) eq -1 ) { // invoke page status = requestPage( fullurl, request.params.rebuildTimeout ); WriteOutput('
Rebuilt expired #fullURL# #status#
'); } } // Delete if( request.params.action eq 'Delete' OR (request.params.action eq 'RebuildIfHit' AND hitCount eq 0) ) { WriteOutput('
Deleting expired non-hit cache #cache#
'); StructDelete( application.CS_PageParamCache[type][element],cache ); LogIt('Deleting expired non-hit cache #cache#'); } } // if cache has not been used in the past N minutes (defaults to 240) kill the cache else if( request.params.MaxUnusedMinutes neq 0 AND DateCompare( lastuse, DateAdd( 'n', -1 * request.params.MaxUnusedMinutes, now() ) ) eq -1 ) { WriteOutput('
Deleting unused #cache#. Last use: #dtf(lastuse)#
'); StructDelete( application.CS_PageParamCache[type][element],cache ); LogIt('Deleting unused #cache#. Last use: #dtf(lastuse)#'); } WriteOutput('');
var ret_url = ''; var qry = ''; select SitePages.Filename, Subsites.subsiteurl from SitePages, Subsites where SitePages.SubsiteID = Subsites.ID AND SitePages.ID = if( qry.recordcount eq 1 ) ret_url = qry.subsiteurl & qry.filename; logIt("Error in GetPage() - #cfcatch.message# #cfcatch.detail#"); var start = GetTickCount(); var end = ''; var tc = 0; end = GetTickcount(); tc = end - start; logIt("Rebuilt #attributes.fullurl# [#cfhttp.statusCode#] [#tc# ms]"); logIt( "Error in requestPage() - #cfcatch.message# #cfcatch.detail#" ); var elType = ReplaceNoCase(arguments.name, 'custom:', '' ); var qry = ''; var retID = 0; // Build memory cache structure so we don't have to run query on every run of background job if( NOT StructKeyExists( application,'CS_PageParamCacheElementNames' ) ) application.CS_PageParamCacheElementNames = StructNew(); if( StructKeyExists( application.CS_PageParamCacheElementNames, elType ) ) retID = application.CS_PageParamCacheElementNames[elType].elementTypeID; else { application.CS_PageParamCacheElementNames[elType] = StructNew(); application.CS_PageParamCacheElementNames[elType].elementTypeID = 0; } select ID from AvailableControls where ShortDesc = Name = if( qry.recordcount eq 1 ) { // set ID to return retID = qry.ID; // cache off so query is not needed next time application.CS_PageParamCacheElementNames[elType].elementTypeID = qry.ID; } var qry = ''; select Max(DateApproved) As DateApproved from Data_FieldValue where FormID = AND VersionState = 2 var filename = expandPath( "/commonspot/logs" ) & "/" & DateFormat( now(), "yyyymmdd" ) & "-param-cache.log";