Open PMunch opened 4 years ago
That would be nice, but would be much more sophisticated. This is just a simple memoization macro, not a full-fledged cache. Deleting the cache is useful between one call to to the memoized function and the other, when the function is recursive, but I am not sure it makes sense to make this package much more complex
Wouldn't have to be that much more sophisticated. Even something simple inserted here: https://github.com/andreaferretti/memo/blob/master/memo.nim#L145-L146 to just do cache.len * (sizeof(inputArgumentType) + sizeof(outputArgumentType))
and some kind of evict random key thing would go a long way to make the caching just a little bit more customizable.
I wanted to do this, but couldn't find the time these days. If you are willing to open a PR, that would be ok for me
It would be nice to have a bit more granularity than just "delete the entire cache", for example a way of setting the size of the cache, or a way to clean the least used entries.