-
-
Save nolandubeau/bce443adc1030269475a to your computer and use it in GitHub Desktop.
Coldbox Cache Error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function incident(event){ | |
var cacheKey = "incident-#rc.id#"; | |
//Check if incident exists in cache | |
if(cache.lookup( cacheKey ) ){ | |
return cache.get( cacheKey ); | |
} | |
//incident isn't in the cache | |
rc.httpResource = "myendpoint/#rc.id#"; | |
local.callResult = api.send(argumentCollection=rc); | |
if(local.callresult.responseheader.status_code == 200){ | |
local.incident = deserializeJSON(local.callResult.rawResponse); | |
//check to see if the incident is active | |
//if it isn't cache it | |
if(local.incident.active EQ 0){ | |
cache.set(cacheKey, local.callResult.rawResponse, 120, 20); | |
} | |
return local.incident; | |
} | |
if(isArray(local.callresult.response)){ | |
prc.errorsArr = local.callresult.response; | |
throw(''); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment