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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.