Last active
August 29, 2015 14:02
-
-
Save myndzi/2912bf7e27dfd14e83a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('bluebird'), | |
redis = require('redis'); | |
var db = redis.createClient(); | |
Promise.promisifyAll(Object.getPrototypeOf(redis), { suffix: '$' }); | |
function _scan(cmd, key) { | |
function recurse(ttl, cur) { | |
return cmd(key, cur).then(function (cur, val) { | |
if (cur) { | |
ttl.push(val); | |
return recurse(ttl, cur); | |
} | |
return ttl; | |
}); | |
}; | |
return recurse([], 0); | |
}; | |
function scan = _scan.bind(null, db.scan$.bind(db)); | |
function sscan = _scan.bind(null, db.sscan$.bind(db)); | |
function lscan = _scan.bind(null, db.lscan$.bind(db)); | |
function hscan = _scan.bind(null, db.hscan$.bind(db)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment