mirror of
https://github.com/amark/gun.git
synced 2025-06-05 13:46:43 +00:00
cache remote files, quick ugly test experiment?
This commit is contained in:
parent
fe3a25682a
commit
faa776a8e5
20
lib/rfsmix.js
Normal file
20
lib/rfsmix.js
Normal file
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user