allow --pattern to be used along with --bigkeys (#3586)

Adds --pattern option to cli's --bigkeys, --hotkeys & --scan modes
This commit is contained in:
Wagner Francisco Mezaroba 2020-08-11 19:57:21 +01:00 committed by GitHub
parent 82451a4717
commit e2a71338eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1846,7 +1846,8 @@ static void usage(void) {
" --hotkeys Sample Redis keys looking for hot keys.\n" " --hotkeys Sample Redis keys looking for hot keys.\n"
" only works when maxmemory-policy is *lfu.\n" " only works when maxmemory-policy is *lfu.\n"
" --scan List all keys using the SCAN command.\n" " --scan List all keys using the SCAN command.\n"
" --pattern <pat> Useful with --scan to specify a SCAN pattern.\n" " --pattern <pat> Keys pattern when using the --scan, --bigkeys or --hotkeys\n"
" options (default: *).\n"
" --intrinsic-latency <sec> Run a test to measure intrinsic system latency.\n" " --intrinsic-latency <sec> Run a test to measure intrinsic system latency.\n"
" The test will run for the specified amount of seconds.\n" " The test will run for the specified amount of seconds.\n"
" --eval <file> Send an EVAL command using the Lua script at <file>.\n" " --eval <file> Send an EVAL command using the Lua script at <file>.\n"
@ -7275,7 +7276,13 @@ static void pipeMode(void) {
*--------------------------------------------------------------------------- */ *--------------------------------------------------------------------------- */
static redisReply *sendScan(unsigned long long *it) { static redisReply *sendScan(unsigned long long *it) {
redisReply *reply = redisCommand(context, "SCAN %llu", *it); redisReply *reply;
if (config.pattern)
reply = redisCommand(context,"SCAN %llu MATCH %s",
*it,config.pattern);
else
reply = redisCommand(context,"SCAN %llu",*it);
/* Handle any error conditions */ /* Handle any error conditions */
if(reply == NULL) { if(reply == NULL) {