Exemplo n.º 1
0
 def __init__(self, config):
     CacheInterface.__init__(self, config)
     self.db = SqliteDict(self.config[u"cache"][u"file"], autocommit=True)
     self.expiration = self.config[u"cache"].get(u"expiration", 86400)
     def closer():
         try:
             self.db.close()
         except Exception:
             logger.exception("Exception closing file cache")
     atexit.register(closer)
    def __init__(self, config):
        CacheInterface.__init__(self, config)
        self.expiration = self.config[u"cache"].get(u"expiration", 86400)
        self.compression = self.config[u"cache"].get(u"compression", 0)
        servers = self.config[u"cache"][u"servers"]
        binary_mode = self.config[u"cache"][u"binary"]
        self.mc = pylibmc.Client(servers, binary=binary_mode)
        self.mc.behaviors["hash"] = "md5"
        compression_mode = 1 if self.compression else 0
        self._set_kwargs = {"time": self.expiration,
                            "min_compress_len": compression_mode}

        pool_size = self.config[u"cache"].get(u"pool_size", 4)
        self.pool = pylibmc.ClientPool()
        self.pool.fill(self.mc, pool_size)
        self._init_memcache()