Beispiel #1
0
 def invalidate(self):
     """Invalidates the cache (i.e. removes all cache files)."""
     if self.readonly:
         raise CacheIOError("Cannot invalidate a readonly cache.")
     self._close_fd()
     with self._index:
         for path in self.get_files():
             self.remove_file(path)
Beispiel #2
0
 def _load_index_file(self):
     with open(self.index_path, "rb") as f:
         self.version = pickle.load(f)
         if (self.version[0] > self.VERSION
                 or self.version[1] > pickle.HIGHEST_PROTOCOL):
             raise CacheIOError("Unsupported cache index file format.")
         self._index = pickle.load(f)
     assert isinstance(self.version, tuple)
     assert isinstance(self._index, dict)