Skip to content

Instantly share code, notes, and snippets.

@justinobney
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save justinobney/651dbd0a6e07948d0f6f to your computer and use it in GitHub Desktop.

Select an option

Save justinobney/651dbd0a6e07948d0f6f to your computer and use it in GitHub Desktop.
var cache = {};
function checkCache(key){
if(cache[key]){
return cache[key];
} else {
// do some long/expensive action
// ex: calculation, ajax, etc...
cache[key] = Math.random();
return cache[key];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment