Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created November 13, 2009 19:22
Show Gist options
  • Select an option

  • Save brandon-beacher/234086 to your computer and use it in GitHub Desktop.

Select an option

Save brandon-beacher/234086 to your computer and use it in GitHub Desktop.
var http = require('http');
var cache = {};
var Cache = {};
Cache.fetch = function(key, callback) {
var hit = cache[key];
if (!hit) {
hit = callback();
cache[key] = hit;
}
return hit;
};
process.mixin(exports, Cache);
var Cache = require('cache');
Cache.fetch('key', function() {
return "value";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment