From 8d4444cfb94d6fe9dce412f8289ff9713c9a2cba Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 28 May 2018 21:18:18 +1000 Subject: [PATCH] Provide our own MessagePack serialiser class for django-redis, since the included one doesn't work properly with msgpack <= 0.5.4 --- lemoncurry/msgpack.py | 11 +++++++++++ lemoncurry/settings/base.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 lemoncurry/msgpack.py diff --git a/lemoncurry/msgpack.py b/lemoncurry/msgpack.py new file mode 100644 index 0000000..1cd399f --- /dev/null +++ b/lemoncurry/msgpack.py @@ -0,0 +1,11 @@ +import msgpack + +from django_redis.serializers.base import BaseSerializer + + +class MSGPackModernSerializer(BaseSerializer): + def dumps(self, value): + return msgpack.dumps(value) + + def loads(self, value): + return msgpack.loads(value) diff --git a/lemoncurry/settings/base.py b/lemoncurry/settings/base.py index 13e2cd7..6251921 100644 --- a/lemoncurry/settings/base.py +++ b/lemoncurry/settings/base.py @@ -157,7 +157,7 @@ CACHES = { 'KEY_PREFIX': 'lemoncurry', 'OPTIONS': { 'PARSER_CLASS': 'redis.connection.HiredisParser', - 'SERIALIZER': 'django_redis.serializers.msgpack.MSGPackSerializer', + 'SERIALIZER': 'lemoncurry.msgpack.MSGPackModernSerializer', }, 'VERSION': 2, }