Skip to content

Commit

Permalink
slight optimization to hmset, mset, and msetnx for both clarity and s…
Browse files Browse the repository at this point in the history
…peed
  • Loading branch information
andymccurdy committed Aug 19, 2010
1 parent 91c0e61 commit 16c0eff
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions redis/client.py
Expand Up @@ -587,7 +587,8 @@ def mget(self, keys, *args):
def mset(self, mapping):
"Sets each key in the ``mapping`` dict to its corresponding value"
items = []
[items.extend(pair) for pair in mapping.iteritems()]
for pair in mapping.iteritems():
items.extend(pair)
return self.execute_command('MSET', *items)

def msetnx(self, mapping):
Expand All @@ -596,7 +597,8 @@ def msetnx(self, mapping):
none of the keys are already set
"""
items = []
[items.extend(pair) for pair in mapping.iteritems()]
for pair in mapping.iteritems():
items.extend(pair)
return self.execute_command('MSETNX', *items)

def move(self, name, db):
Expand Down Expand Up @@ -1144,7 +1146,8 @@ def hmset(self, name, mapping):
in the hash ``name``
"""
items = []
[items.extend(pair) for pair in mapping.iteritems()]
for pair in mapping.iteritems():
items.extend(pair)
return self.execute_command('HMSET', name, *items)

def hmget(self, name, keys):
Expand Down

0 comments on commit 16c0eff

Please sign in to comment.