Move search() and scan() scan to its own function
Use async.eachLimit() to scan keys