Redis keys function for match with multiple pattern

2.9k views Asked by At

How can I find keys with multiple match pattern, for example I have keys with

foo:*, event:*, poi:* and article:* patterns.

How can I find keys with redis keys function for match with foo:* or poi:* pattern, its like

find all keys with prefix foo:* or poi:*
1

There are 1 answers

3
Didier Spezia On BEST ANSWER

You should not do this. KEYS is mainly a debug command. It is not supposed to be used for anything else.

Redis is not a database supporting ad-hoc queries: you are supposed to provide access paths for the data you put into Redis (using extra set or hash or zset indexes).

If you really need to run arbitrary boolean expressions on keys to select data, I would suggest to do it offline by using the rdb-redis-tools package.