Cache does not persist between Python instances
MrTomRod opened this issue · comments
Thomas Roder commented
I ran this code in two separate Python consoles:
from mezmorize import Cache
cache = Cache(CACHE_TYPE='filesystem', CACHE_DIR='/tmp/mezmorize')
@cache.memoize()
def fn(a, b):
print('I ran!')
pass
The function was run twice, i.e. It was not cached. It would be nice if there were an option to keep caches between runs. This is what the syntax could look like:
cache = Cache(CACHE_TYPE='filesystem', CACHE_DIR='/tmp/mezmorize', PERSIST=True)
I failed to understand how the library works, so I don't know whether it's possible to implement this.
I suspect that the hash of the function fn
changes. If so, PERSIST could just create a hash for the location of the function, i.e. f'{fn.__module__}.{fn.__name__}'
-> '__main__.fn'