disqus / nydus

Nydus is a Python toolkit for managing database connections and routing operations, primarily for Redis
Apache License 2.0
380 stars 38 forks source link

Redis KEYS Method #30

Closed woozyking closed 11 years ago

woozyking commented 11 years ago

Hi,

When I call redis.keys("*") method, it would give me only the keys from one node from the cluster.

So I gave the map() method a try:

with redis.map() as c:
    r = [c.keys(*)]

Which still gives me the single node's values. Maybe I just used the map() wrong. Then I tried redis methods like info() and dbsize(), they all report back a list of values representing the whole cluster.

Please let me know if it's possible to achieve this.

Thanks in advance.

dcramer commented 11 years ago

There's no good way to do this at the moment. You'd have to call out to each individual connection or setup a custom router which understood the keys command and ran it on all nodes.

It's pretty awful but you can do this:

keys = []
for db in cluster:
  keys.extend(cluster[db].keys())

On Monday, March 25, 2013 at 3:03 PM, oEL wrote:

Hi, When I call redis.keys("") method, it would give me only the keys from one node from the cluster. So I gave the map() method a try: with redis.map() as c: r = [c.keys()]

Which still gives me the single node's values. Maybe I just used the map() wrong. Then I tried redis methods like info() and dbsize(), they all report back a list of values representing the whole cluster. Please let me know if it's possible to achieve this. Thanks in advance.

— Reply to this email directly or view it on GitHub (https://github.com/disqus/nydus/issues/30).

woozyking commented 11 years ago

Thanks @dcramer, that's not so bad, given that my use case here is just to occasionally inspect the keys of all nodes.