How can I find the count of all the keys that has a matching pattern.
For example, there are two keys abc:random-text-1
and abc:random-text-2
.
DISCLAIMER I hope this old answer haven't damaged any production systems, with millions of keys. If you still want to still count the matching keys of redis in production for some reason, better use scan with a match pattern.
If you simply search with KEYS, with your redis client, you will get a number list of all you matching keys, right?
e.g.
KEYS abc:*
will give you
1) abc:random-text-1
2) abc:random-text-2
or you can run the following:
./redis-cli KEYS "abc:*" | wc -l
and you will get 2
as an output.