Closed manishkrishan closed 2 years ago
Yes, you can use the SCAN + DEL to do the job:
auto cursor = 0LL;
auto pattern = "mykeys*";
while (true) {
std::unordered_set<std::string> keys;
cursor = redis.scan(cursor, pattern, std::inserter(keys, keys.begin()));
if (cursor == 0) {
break;
} else {
redis.del(keys.begin(), keys.end());
}
}
NOTE: Do not use KEYS command to match keys in production env.
Regards
Since there's no update, I'll close this issue.
Regards
I am looking a way to delete all keys matching to a pattern like "mykeys*" using redis-plus-plus. Any suggestion, I know using redis CLI it is possible.
I am using redis cluster.