Standard memcache client uses pickle as a serialization format. It can be handy to use json, especially when another component (e.g. backend) doesn't know pickle, but json yes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import memcache
import simplejson
class SimplejsonWrapper(object):
def __init__(self, file, protocol=None):
self.file = file
def dump(self, value)
simplejson.dump(value, self.file)
def load(self):
return simplejson.load(self.file)
cache = memcache.Client(['127.0.0.1:11211'], pickler=SimplejsonWrapper, unpickler=SimplejsonWrapper)
|
More like this
- Generate and render HTML Table by LLyaudet 1 day, 23 hours ago
- My firs Snippets by GutemaG 5 days, 7 hours ago
- FileField having auto upload_to path by junaidmgithub 1 month, 1 week ago
- LazyPrimaryKeyRelatedField by LLyaudet 1 month, 2 weeks ago
- CacheInDictManager by LLyaudet 1 month, 2 weeks ago
Comments
Please login first before commenting.