-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Cache persistence #33
Comments
@ldasilva-net cache is not exposed in any way, and there's no way to access it as whole. I can probably introduce some function so copy of cache is returned on request, and that cache can be injected via some external mean. |
@medikoo ok, well... great! Thanks a lot for considering this. |
Just thinking... I dont know the internal funcionality of your lib, but I presume that the object maintains all the cache in memory. Maybe you can consider using some system stored on disk for saving on long term thought caches, where the object use the disk for store/read the cache. For example, in my scenario, I have information that rarely changes, so my idea is that most of the request mantein cached.... ok, you need a realy lot of situations for full the memory, I'm just thinking out loud. |
@ldasilva-net it'll never become internal part of memoizee, as memoizee is about doing one thing, and persistence is rare custom case that can be easily done aside. I'm also not really convinced at this point to introduce option of cache import/export, as as I pointed it can work reliably only in some configuration cases, so functionality from start will be partially broken, and that opens door for other issues. Can you explain better your use case? What exactly do you memoize that you'd like to store persistently? Do you really need it, or is it just nice to have feature? |
@medikoo I explain the scenario: I have a API build in Node with Express. The methods in there go to the database where execute querys and aggregations who in some cases are heavy (for process time), then response a JSON with the data (so I'm using now primitive mode). All this method are cached and its work very very well. |
I have the same use case as @LiberD |
I plan a bigger overhaul of this package this year, I'll make sure then that this use case is addressed |
hey @medikoo ! before all: thanks for a great package ! |
@xaiki not yet, and not very soon, Earliest in 1st quarter of next year |
Hi @medikoo First of all, great work on this module :) I have a use case very close to what was explained here. What I want to do, is when the maxAge is reached and you need to call the original function again, if this fails, I want to respond what was in the cache before (even if it is stale). For that, I need read access to the cache so that I'm able to respond something even if the original function call fails. What do you think? An import/export solution would solve my issue? In my case, it's just export. Many thanks. |
I'd like to use the cache import/export functionality in my test-suite (jest). For my use, I will monkey patch the http client library (axios) used in my test-suite to optionally use a memoizee'd version. Then when executing the test suite I can choose to run service-level tests (by running suite without loading the memoizee cache or injecting the custom axios implementation) or to run faster-executing unit-test-like tests (by running suite with loaded memoizee cache and memoizee'd axios). |
You definitely have the best js memoization library, and while I understand that it wasn't the original purpose, I do think persistence would be an impactful feature (e.g., every http request library has multiple caching/VCR libraries). If you had a moment to document your desired approach, there may be folks (myself included) that could help. |
Guys, it's been four years lol, maybe it's time to use a different library Here's one: https://github.com/borisdiakur/memoize-fs |
Caching to disk is not a scalable solution IMHO |
Even if this statement is true (and I doubt it's wholesale true), not everything needs to be scalable. Needing disk cache + function memoize is not at all an uncommon or unreasonable need. This library in python has a TTL disk cache with a Related issue on another js memoize library: sindresorhus/memoize#86
Thanks for this, I'm going to try it out. Had a hard time finding alternatives. Edit: Unfortunately it's |
I use memoize in a Node Web Service application.
Can I save the cache in disk and then when the service begin assign to the memoize object again?
Thanks
The text was updated successfully, but these errors were encountered: