Skip to content

Commit

Permalink
support storage manager
Browse files Browse the repository at this point in the history
  • Loading branch information
bahalool committed Nov 18, 2018
1 parent 08e1054 commit 84883f2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ class RedisAdapter {
return this._set({ path: pathLib.join('/', pathLib.join('/', options.Path)), data: options.Data });
}


async list(options) {
return new Promise((resolve, reject) => {
let keys = [];
const stream = client.scanStream({ match: pathLib.join('/', options.Path, '*') });
stream.on('data', (data) => {
keys = keys.concat(data);
});
stream.on('end', () => {
return resolve(keys.map(k => ({ Path: k })));
});
stream.on('error', () => {
return reject();
});
});
}

async delete(options) {
return client.del(options.Path);
}

_set(options) {
return new Promise((resolve, reject) => {
const { data, path } = options;
Expand Down

0 comments on commit 84883f2

Please sign in to comment.