django-redis-cache
django-redis-cache copied to clipboard
Error with redis 3.0.0
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.
PR #161 will fix that
This was resolved with 34dadba20a0c2345ee07419c354dae567382ada3. Thanks!
Actually, can we open this back up as tracking for the need of Redis 3.x compatibility?
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.
https://github.com/niwinz/django-redis/issues/342
I think I have a workaround by simply subclassing unicode
and attaching an attribute that we can use to store the versioned key.
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.