diskstore
a basic local cache implementation
Introduction
A basic file cache implementation. It just providers low-level APIs (get, set, delete) to allow you read & atomic write from file cache. You can also create your implementation by inheriting or wrapping it.
Install
$ npm install diskstore --save
APIs
new DiskStore(options)
- {String} cacheDir - root cache dir
* get(relativePath)
read data from relativePath if the file exists.
- {String} relativePath - file path relative to root cache dir
* set(relativePath, data)
write data to relativePath
- {String} relativePath - file path relative to root cache dir
- {Buffer|String} data - the data
* delete(relativePath)
delete the file
- {String} relativePath - file path relative to root cache dir
Usage
const diskStore = new DiskStore({
cacheDir: '/path/cache',
});
yield diskStore.set('a/b/c', 'c');
let data = yield diskStore.get('a/b/c');
assert.deepEqual(data, new Buffer('c'));
yield diskStore.delete('a/b/c');
data = yield diskStore.get('a/b/c');
assert(data === null);
License
MIT