简体   繁体   中英

get “keypattern*” doesn't work in Redis Cluster

In a Redis environment , we are familiar with commands like

:keys *

:get pattern

But these dont work easily in Cluster.

I found a workaround for "keys *" ( although its slow). But I am stuck with "get pattern "

The reason , why it doesnt work, as per my understanding is..

Each of the redis nodes uses an algorithm to find the hash of any key , and it already knows which hash blocks is owned by which node. So it redirects the call ( get/set/hmget/.....) to that particular node.

Now in case of a pattern, it has no way to identify the owner of the hash , until it gets the actual key.

Suppose the key is xyz, and the hash of it is 100 if I use xy*, no way it can get the possible list of hash, of the keys, which start with xy

I was wondering, if anyone can show some light here, or if my understanding is wrong( I will be happy, if it is) or if there is any tool ( like jedis...) available, which is suitable for my requirement

Thanks !

:keys *

Never use in production.

:get pattern

There isn't anything like that in Redis.

To answer your question, you need connect to each node in the cluster and look for your keys independently in each, for example with SCAN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM