Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Coldbox Cache Error
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