Google Groups

Re: Redis update #7 python code and question

Josiah Carlson Sep 5, 2010 10:53 PM
Posted in group: Redis DB
You need to know the name of all of your hash members in order to
perform a pipelined hget.  But since you are scattering your hash
members over a bunch of different redis hashes (and even worse, you
are taking standard key/value entries and stuffing them into redis
hashes), that's not possible.  That's also why you can't use hmgetall.

If you are trying to use your get_hash_name() as a method of sharding,
you are making a mistake with regards to it's use with hashes (and
really, your conflation of standard set() with hset() is part of

Really, your set() method should be renamed and look something like...

def hset(self, key, field, value):
    redis.Redis.hset(self, self.get_hash_name(key), field, value)

Other methods you list should be changed appropriately and similarly.

Is the code you have provided a mistake?  What are you trying to do?

 - Josiah

On Sun, Sep 5, 2010 at 8:47 PM, adamjamesdrew <> wrote:
> import hashlib,redis
> sha1 = hashlib.sha1
> class RedisWrapper(redis.Redis):
> def get_hash_name(self,key):
> return sha1(key).hexdigest()[:4]
> def exists(self,key):
> return self.hexists(self.get_hash_name(key))
> def get(self,key):
> return self.hget(self.get_hash_name(key),key)
> def set(self,key,value):
> self.hset(self.get_hash_name(key),key,value)
> def incrby(self,key,incr):
> self.hincrby(self.get_hash_name(key),key,incr)
> My questions is:
> The MGET command is now broken. I use that command for performance
> reasons. Can anyone think of an easy way to implement the MGET with
> comparable performance?
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to
> To unsubscribe from this group, send email to
> For more options, visit this group at