Skip to content
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

Error with redis 3.0.0 #160

Open
andialbrecht opened this issue Nov 15, 2018 · 6 comments
Open

Error with redis 3.0.0 #160

andialbrecht opened this issue Nov 15, 2018 · 6 comments

Comments

@andialbrecht
Copy link

About an hour ago the redis package was released in version 3.0.0. Since then I see the following error when using django-redis-cache:

>>> from django.core.cache import cache
>>> cache.get("foo", None)
Traceback (most recent call last):
  File "/home/andi/.local/lib/python3.6/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/home/andi/.envs/app/lib/python3.6/site-packages/redis_cache/backends/base.py", line 33, in wrapped
    return method(self, client, key, *args, **kwargs)
  File "/home/andi/.envs/app/lib/python3.6/site-packages/redis_cache/backends/base.py", line 256, in get
    value = client.get(key)
  File "/home/andi/.envs/app/lib/python3.6/site-packages/redis/client.py", line 1207, in get
    return self.execute_command('GET', name)
  File "/home/andi/.envs/app/lib/python3.6/site-packages/redis/client.py", line 754, in execute_command
    connection.send_command(*args)
  File "/home/andi/.envs/app/lib/python3.6/site-packages/redis/connection.py", line 619, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "/home/andi/.envs/app/lib/python3.6/site-packages/redis/connection.py", line 659, in pack_command
    for arg in imap(self.encoder.encode, args):
  File "/home/andi/.envs/app/lib/python3.6/site-packages/redis/connection.py", line 124, in encode
    "byte, string or number first." % typename)
redis.exceptions.DataError: Invalid input of type: 'CacheKey'. Convert to a byte, string or number first.
>>> 

When downgrading redis to 2.10.6 everything works fine.

@drgarcia1986
Copy link
Contributor

PR #161 will fix that

@andialbrecht
Copy link
Author

This was resolved with 34dadba. Thanks!

@fxfitz
Copy link

fxfitz commented Nov 19, 2018

Actually, can we open this back up as tracking for the need of Redis 3.x compatibility?

@sebleier sebleier reopened this Nov 19, 2018
@avelis
Copy link

avelis commented Nov 19, 2018

There is a good discussion on this on the django-redis repo. The main issue I believe is that Redis no longer converts to a string by default. Therefore the CacheKey object needs to return a string.

jazzband/django-redis#342

@sebleier
Copy link
Owner

I think I have a workaround by simply subclassing unicode and attaching an attribute that we can use to store the versioned key.

@cnobile2012
Copy link

Is there a timeline for bringing this code up to date? I'm getting the error below during a pip install.

django-redis-cache 1.8.1 has requirement redis==2.10.6, but you'll have redis 3.1.0 which is incompatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants