0

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 !

user3123372
  • 704
  • 1
  • 10
  • 26

1 Answers1

1

: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

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117
  • set key value, get key , ... like set xyz abc, get xyz, the answer will be abc, and instead of xyz, u can use xy* also, – user3123372 Feb 09 '17 at 04:15