Created
February 21, 2014 13:15
-
-
Save oroce/9134017 to your computer and use it in GitHub Desktop.
singleton-storage sync version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var storage = require("./singleton-storage"); | |
var initalData = {"foo": "bar"}; | |
storage.set( "key1", initialData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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