Provide our own MessagePack serialiser class for django-redis, since the included one doesn't work properly with msgpack <= 0.5.4

This commit is contained in:
Danielle McLean 2018-05-28 21:18:18 +10:00
parent b59962a119
commit 8d4444cfb9
Signed by: 00dani
GPG key ID: 8EB789DDF3ABD240
2 changed files with 12 additions and 1 deletions

11
lemoncurry/msgpack.py Normal file
View file

@ -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)

View file

@ -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,
}