

def retrieve(self, host, path, params):
    key = hash((host, path, frozenset(list(params.items()))))
    self.count += 1
    cached = self.cache.get(key, None)
    if cached:
        cacheFile = None
    else:
        cacheFile = join(self.tempdir, (str(key) + '.cache'))
        if exists(cacheFile):
            self.log(('%s: retrieving from disk' % path))
            f = open(cacheFile, 'rb')
            cached = self.cache[key] = pickle.loads(zlib.decompress(f.read()))
            f.close()
    if cached:
        if (time.time() < cached[0]):
            self.log(('%s: returning cached document' % path))
            return cached[1]
        self.log(('%s: cache expired, purging!' % path))
        del self.cache[key]
        if cacheFile:
            os.remove(cacheFile)
    self.log(('%s: not cached, fetching from server...' % path))
    return None

dataset/ETHPy150Open ntt/eveapi/apitest.py MyCacheHandler.retrieve/original