diff --git a/lib/rfsmix.js b/lib/rfsmix.js new file mode 100644 index 00000000..6b6c126d --- /dev/null +++ b/lib/rfsmix.js @@ -0,0 +1,20 @@ +module.exports = function(opt, store){ + var rfs = require('./rfs')(opt); + var p = store.put; + var g = store.get; + store.put = function(file, data, cb){ + rfs.put(file, data, function(err, ok){ + if(err){ return cb(err) } + console.log("rfs3 cached", file); + p(file, data, cb); + }); + } + store.get = function(file, cb){ + rfs.get(file, function(err, data){ + console.log("rfs3 hijacked", file); + if(data){ return cb(err, data) } + g(file, cb); + }); + } + return store; +} \ No newline at end of file diff --git a/lib/rs3.js b/lib/rs3.js index e4f57f7d..2ad03e8b 100644 --- a/lib/rs3.js +++ b/lib/rs3.js @@ -98,6 +98,7 @@ function Store(opt){ }); }; //store.list(function(){ return true }); + require('./rfsmix')(opt, store); // ugly, but gotta move fast for now. return store; }