#33826: Redis client raises exceptions in the RedisCache backend delete_many and
set_many methods when used with empty keys or data
-----------------------------------------------+--------------------------
               Reporter:  Christos Kopanos     |          Owner:  (none)
                   Type:  Bug                  |         Status:  assigned
              Component:  Core (Cache system)  |        Version:  4.0
               Severity:  Normal               |       Keywords:
           Triage Stage:  Unreviewed           |      Has patch:  1
    Needs documentation:  0                    |    Needs tests:  0
Patch needs improvement:  0                    |  Easy pickings:  0
                  UI/UX:  0                    |
-----------------------------------------------+--------------------------
 I am not sure the behavior described below is the intended (in the sense
 that the code utilizing the cache backend should make sure to place those
 checks introduced before calling delete_many or set_many, however looking
 at the Database backend implementation similar checks do exist when
 calling the delete_many method and since I jumped into this bug using the
 redis backend a fix is needed I think to address this issue.

 **Case**

 If the 2 methods call the underlying redis client DEL and MSET commands
 with
 empty parameters then an exception will be thrown by the redis client:

 redis.exceptions.ResponseError: wrong number of arguments for 'del'
 command

 and

 redis.exceptions.ResponseError: Command # 1 (MSET) of pipeline caused
 error: wrong number of arguments for 'mset' command

 respectively.

 **Steps to reproduce**

 Using


 {{{
 USE_TZ = False
 DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME":
 "mydatabase"}}

 CACHES = {
     "default": {
         "BACKEND": "django.core.cache.backends.redis.RedisCache",
         "LOCATION": "redis://localhost:6379",
     }
 }
 }}}


 as a settings file run a shell


 {{{
 ./manage.py shell --settings myapp.settings
 from django.core.cache import cache
 cache.delete_many([])
 }}}


 raises exception redis.exceptions.ResponseError: wrong number of arguments
 for 'del' command


 {{{
 cache.set_many({})
 }}}


 raises exception redis.exceptions.ResponseError: Command # 1 (MSET) of
 pipeline caused error: wrong number of arguments for 'mset' command

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33826>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070181cf43ebfe-ba6e3c20-fbd1-456a-993a-c34fa66af075-000000%40eu-central-1.amazonses.com.

Reply via email to