def save_cache(self, file): import json with open(file, 'w') as f: json.dump(self.cache, f, indent=4, sort_keys=True)