How to get the number of keys matching a particular pattern

24 views
Skip to first unread message

Santos Das

unread,
Nov 30, 2017, 12:22:45 PM11/30/17
to Redis DB
Hi,

I am using Redis cluster.  Is there a wayI can get the key counts for a matching a pattern?
For example, I want to find out how many keys start with XYZ?

ANy info would be helpful

thanks, santos

Jan-Erik Rediger

unread,
Nov 30, 2017, 12:37:17 PM11/30/17
to redi...@googlegroups.com
That's general not a thing Redis is good at.
There are two commands that could do it per node:
KEYS (http://redis.io/commands/keys) - Don't ever use that!
SCAN (https://redis.io/commands/scan) - Still requires you to do a full scan through the keyspace

If this is a thing you need to do regurarly it's time to rethink your
data structure.
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
> To post to this group, send email to redi...@googlegroups.com.
> Visit this group at https://groups.google.com/group/redis-db.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages