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

Use string values for django-cache keys #230 #242

Merged
merged 7 commits into from Oct 11, 2021
4 changes: 4 additions & 0 deletions django_celery_results/backends/cache.py
Expand Up @@ -3,6 +3,7 @@
from celery.backends.base import KeyValueStoreBackend
from django.core.cache import cache as default_cache
from django.core.cache import caches
from kombu.utils.encoding import bytes_to_str


class CacheBackend(KeyValueStoreBackend):
Expand All @@ -15,12 +16,15 @@ def __init__(self, *args, **kwargs):
self.serializer = 'pickle'

def get(self, key):
key = bytes_to_str(key)
return self.cache_backend.get(key)

def set(self, key, value):
key = bytes_to_str(key)
self.cache_backend.set(key, value, self.expires)

def delete(self, key):
key = bytes_to_str(key)
self.cache_backend.delete(key)

def encode(self, data):
Expand Down