Skip to content

Instantly share code, notes, and snippets.

@nolandubeau
Created September 19, 2012 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolandubeau/bce443adc1030269475a to your computer and use it in GitHub Desktop.
Save nolandubeau/bce443adc1030269475a to your computer and use it in GitHub Desktop.
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