-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saving cache to file and reading from it #68
Comments
You should use a persistent dictionary type for that (i.e. one that is saved to a file), like
but I don't know if anyone has made such a |
Any idea on how this dict type can be constructed? If it would be possible for me I can try it. |
That's a big question! If you google for The easier solution would be to have a struct PerstitentDict
dict::Dict
end Then on |
Thanks, this is what I was also looking for. :) |
I just tried this with https://github.com/jw3126/DiskBackedDicts.jl. Note that you could also use https://github.com/blenessy/PersistentCollections.jl. Regardless of our disc-backed dictionary, theres a slight hiccup: Memoize calls For now, I can get things to work by hacking an override for the
|
You can try removing it and see what breaks in the tests. I doubt that we'll be able to take it out in a non-breaking release, but I can definitely see that on the 0.5 milestone... FWIW, this is almost certainly about being revision-friendly. It came from 4 years ago (1a3b4d5), so it predates Revise.jl. I'd say the key property to keep here is that if I change the definition of a memoized function, it should reset the cache. Because of the |
For now, I've opted to wrap my dictionary in the following:
This solution works for me for now. However, I don't think that memoize can be truly revision-friendly without significant changes. For example, revisions of the same function which don't go through Memoize aren't tracked, nor are revisions of functions which the memoized function calls, even if those functions go through Memoize. To give two examples:
To clarify, I think it might be possible (and perhaps useful) to create an efficient 265-aware memoize if we keep track of the world age bounds of the method cache (and keep a separate cache for each method like in #59, rather than having one cache per function like in the current version). However, the current version of Memoize only supports a subset of such revisions, and it might be better for the cache to never invalidate unless asked explicitly. |
Hi, I am a new user of memoize and need some help.
As I can see, memoize can use dictionary as a cache which I can probably write to a file later. Can I read this dictionary later and load it into the cache?
I checked the asked questions but it seems this feature doesn't exist(?)
The text was updated successfully, but these errors were encountered: