mantafs
v0.1.0
Published
`fs` compatible API that caches/stages from Joyent Manta
Downloads
2
Keywords
Readme
mantafs
mantafs
provides an API for interacting with
Joyent Mantathat is drop-in compatible
with node's fs API. This API automatically
manages interactions with Manta by maintaining a local on-disk cache; this will
give you a dramatic performance increase (since in most cases the WAN is
avoided), at the cost of no longer being consistent at any point in time with
your data in Manta (i.e., this is 'A' in CAP).
Usage
As always:
npm install mantafs
Then to use:
var assert = require('assert');
var manta = require('manta');
var mantafs = require('mantafs');
var fs = mantafs.createClient({
files: 10000, // how many local files to keep
path: '/var/tmp/mantafs', // where to stash cached files
sizeMB: 1000, // how much disk space to consume
ttl: 3600, // if no cache-control header, the default TTL
manta: manta.createClient({ // must provide a Manta client
sign: manta.privateKeySigner({
key: fs.readFileSync(process.env.HOME + '/.ssh/id_rsa', 'utf8'),
keyId: process.env.MANTA_KEY_ID,
user: process.env.MANTA_USER
}),
user: process.env.MANTA_USER,
url: process.env.MANTA_URL
})
});
fs.once('ready', function () {
fs.readdir('~~/stor', function (err, files) {
assert.ifError(err);
console.log(files);
fs.close(function (err2) {
assert.ifError(err2);
manta.close();
});
});
});