In one place of my code, I use django_redis to update cache with a lock:
from django.core.cache import cache
with cache.lock('hello'):
# do stuff
In another place, I check whether cache is not locked using:
if not cache.get('hello'):
# do other stuff
However, when lock is set, get
call fails with UnpicklingError: invalid load key, 'f'.
Why is this happening? What am I doing wrong?
You can reproduce this behaviour with this snippet:
from django.core.cache import cache
with cache.lock('hello'):
cache.get('hello')