From e2a71338ebfb719cba94742f1c75ce755cd6074d Mon Sep 17 00:00:00 2001 From: Wagner Francisco Mezaroba Date: Tue, 11 Aug 2020 19:57:21 +0100 Subject: [PATCH] allow --pattern to be used along with --bigkeys (#3586) Adds --pattern option to cli's --bigkeys, --hotkeys & --scan modes --- src/redis-cli.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/redis-cli.c b/src/redis-cli.c index 09f95b507..4df157d20 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -1846,7 +1846,8 @@ static void usage(void) { " --hotkeys Sample Redis keys looking for hot keys.\n" " only works when maxmemory-policy is *lfu.\n" " --scan List all keys using the SCAN command.\n" -" --pattern Useful with --scan to specify a SCAN pattern.\n" +" --pattern Keys pattern when using the --scan, --bigkeys or --hotkeys\n" +" options (default: *).\n" " --intrinsic-latency Run a test to measure intrinsic system latency.\n" " The test will run for the specified amount of seconds.\n" " --eval Send an EVAL command using the Lua script at .\n" @@ -7275,7 +7276,13 @@ static void pipeMode(void) { *--------------------------------------------------------------------------- */ 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 */ if(reply == NULL) {