JSON instead of pickle for memcached

 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

  1. Check Size of Object in memcached by deryck 6 years, 4 months ago
  2. Property Attributes in Memcache by ori 2 years, 5 months ago
  3. cache_smart template tag by michiel_1981 6 years, 1 month ago
  4. Memcache Status by gfranxman 7 years, 1 month ago
  5. Another Memcache Status View by cmheisel 6 years, 2 months ago

Comments

(Forgotten your password?)