Skip to content

Commit db57c72

Browse files
authored
Merge pull request #3 from martinzuern/feature/delete
Added a delete to API
2 parents 1dad594 + d1a7d5d commit db57c72

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ store.save('quote', 'i see dead people', function (err, reply) {
3535
});
3636
});
3737

38+
store.delete('quote', function (err, reply) {
39+
// err: null
40+
// reply: 1
41+
});
3842

3943

4044
var otherStore = new SecureStore({

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,17 @@ SecureStore.prototype.get = function (postfix, key, cb) {
104104
});
105105
};
106106

107+
SecureStore.prototype.delete = function (postfix, key, cb) {
108+
if (typeof cb !== 'function') {
109+
assert(typeof key === 'function', 'must specify a callback');
110+
cb = key;
111+
key = postfix;
112+
postfix = '';
113+
} else {
114+
postfix = ':' + postfix;
115+
}
116+
assert(typeof key === 'string', 'no hash key specified');
117+
this.pool.hdel(this.namespace + postfix, shasum(key), cb);
118+
};
119+
107120
module.exports = SecureStore;

0 commit comments

Comments
 (0)