I\'m using @functools.lru_cache in Python 3.3. I would like to save the cache to a file, in order to restore it when the program will be restarted. How could I
@functools.lru_cache
You can use a library of mine, mezmorize
import random from mezmorize import Cache cache = Cache(CACHE_TYPE='filesystem', CACHE_DIR='cache') @cache.memoize() def add(a, b): return a + b + random.randrange(0, 1000) >>> add(2, 5) 727 >>> add(2, 5) 727