You can use recursion to continue a scan call to completion.
function scanAsync(cursor, pattern, returnSet){ return redisClient.scanAsync(cursor, "MATCH", pattern, "COUNT", "100").then( function (reply) { cursor = reply[0]; var keys = reply[1]; keys.forEach(function(key,i){ returnSet.add(key); }); if( cursor === '0' ){ return Array.from(returnSet); }else{ return scanAsync(cursor, pattern, returnSet) } }); }
Go to Set () to make sure the keys are not duplicated.
myResults = new Set(); scanAsync('0', "NOC-*[^listen]*", myResults).map( function( myResults ){ console.log( myResults); } );
Kai
source share