Skip to content

Instantly share code, notes, and snippets.

@oroce
Created February 21, 2014 13:15
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 oroce/9134017 to your computer and use it in GitHub Desktop.
Save oroce/9134017 to your computer and use it in GitHub Desktop.
singleton-storage sync version
var storage = require("./singleton-storage");
app.get("/data", function( req, res ){
var key = "key1";
var data = storage.get(key);
res.json(data); // data is {"foo":"bar"}
});
var storage = require("./singleton-storage");
var initalData = {"foo": "bar"};
storage.set( "key1", initialData);
var storage = {};
function get(key){
return storage[key];
}
function set(key,data){
storage[key] = data;
}
exports.get = get;
exports.set = set;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment