New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis backend raises exception when calling get/set_multi with empty iterable/mapping #58

Closed
sqlalchemy-bot opened this Issue Jan 12, 2014 · 3 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Jan 12, 2014

Migrated issue, originally created by greggg (greggg)

Calling get_multi with an empty iterable:

#!python

from dogpile.cache import make_region

region = make_region().configure(
    'dogpile.cache.redis',
    arguments={
        'host': 'localhost',
        'port': 6379,
        'db': 0,
        'distributed_lock': True
    }
)
region.get_multi([])

Results in:

  File "/home/gg/dev/sandbox/dogpile.cache/dogpile/cache/region.py", line 509, in get_multi
    backend_values = self.backend.get_multi(keys)
  File "/home/gg/dev/sandbox/dogpile.cache/dogpile/cache/backends/redis.py", line 122, in get_multi
    values = self.client.mget(keys)
  File "/home/gg/.virtualenvs/dogpile/lib/python2.7/site-packages/redis/client.py", line 768, in mget
    return self.execute_command('MGET', *args)
  File "/home/gg/.virtualenvs/dogpile/lib/python2.7/site-packages/redis/client.py", line 461, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/home/gg/.virtualenvs/dogpile/lib/python2.7/site-packages/redis/client.py", line 471, in parse_response
    response = connection.read_response()
  File "/home/gg/.virtualenvs/dogpile/lib/python2.7/site-packages/redis/connection.py", line 339, in read_response
    raise response
ResponseError: wrong number of arguments for 'mget' command

Calling set_multi with an empty mapping:

#!python

from dogpile.cache import make_region

region = make_region().configure(
    'dogpile.cache.redis',
    arguments={
        'host': 'localhost',
        'port': 6379,
        'db': 0,
        'distributed_lock': True
    }
)
region.set_multi({})

Results in:

  File "/home/gg/dev/sandbox/dogpile.cache/dogpile/cache/region.py", line 790, in set_multi
    self.backend.set_multi(mapping)
  File "/home/gg/dev/sandbox/dogpile.cache/dogpile/cache/backends/redis.py", line 142, in set_multi
    self.client.mset(mapping)
  File "/home/gg/.virtualenvs/dogpile/lib/python2.7/site-packages/redis/client.py", line 782, in mset
    return self.execute_command('MSET', *items)
  File "/home/gg/.virtualenvs/dogpile/lib/python2.7/site-packages/redis/client.py", line 461, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/home/gg/.virtualenvs/dogpile/lib/python2.7/site-packages/redis/client.py", line 471, in parse_response
    response = connection.read_response()
  File "/home/gg/.virtualenvs/dogpile/lib/python2.7/site-packages/redis/connection.py", line 339, in read_response
    raise response
redis.exceptions.ResponseError: wrong number of arguments for 'mset' command

The other backends do not raise an exception in these cases, so for consistency, the Redis backend should not either.

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Jun 13, 2014

Michael Bayer (zzzeek) wrote:

Handle empty multi get/set

This fixes #58

b052a62

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Jun 13, 2014

Michael Bayer (zzzeek) wrote:

Merge branch 'empty-multi' of https://bitbucket.org/wichert/dogpile.cache/branch/empty-multi into pr/20
Fixes #58

fdbf2c8

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Jun 13, 2014

Changes by Michael Bayer (zzzeek):

  • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment