]>
git.ipfire.org Git - ipfire.org.git/blob - src/backend/memcached.py
6 from .misc
import Object
8 class Memcached(Object
):
10 self
._connection
= memcache
.Client(["localhost"], debug
=1)
12 def get(self
, key
, *args
, **kwargs
):
13 logging
.debug("Retrieving %s from cache..." % key
)
15 ret
= self
._connection
.get(key
, *args
, **kwargs
)
18 logging
.debug("Found nothing for %s" % key
)
20 logging
.debug("Found object of %s bytes for %s" % (len(ret
), key
))
24 def get_multi(self
, keys
, *args
, **kwargs
):
25 logging
.debug("Retrieving keys from cache: %s" % keys
)
27 ret
= self
._connection
.get_multi(keys
, *args
, **kwargs
)
30 logging
.debug("Found nothing for %s" % keys
)
32 logging
.debug("Found object of %s bytes for %s" % (len(ret
), keys
))
36 def add(self
, key
, data
, *args
, **kwargs
):
38 logging
.debug("Putting nothing into cache for %s" % key
)
40 logging
.debug("Putting %s bytes into cache for %s" % (len(data
), key
))
42 return self
._connection
.add(key
, data
, *args
, **kwargs
)
44 def set(self
, key
, data
, *args
, **kwargs
):
46 logging
.debug("Putting nothing into cache for %s" % key
)
48 logging
.debug("Putting %s bytes into cache for %s" % (len(data
), key
))
50 return self
._connection
.set(key
, data
, *args
, **kwargs
)
52 def delete(self
, key
, *args
, **kwargs
):
53 return self
._connection
.delete(key
, *args
, **kwargs
)
56 logging
.debug("Incrementing key %s" % key
)
58 return self
._connection
.incr(key
)