-
Notifications
You must be signed in to change notification settings - Fork 15
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
Service keeps all records in memory #116
Comments
Disregard my delete comment 😆 exactly what you said should work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
The storage item is only retrieved when needed. Meaning that the entire collection is not in memory except when needed.
Actual behavior
On the first service call, the entire storage collection is loaded into memory. The collection is then not read from storage again.
I totally understand why current implementation works the way it does, because its an easy extension of the feathers-memory service. But I would also like to see an implementation that does not keep the collection in memory when not needed. I am using localstorage services to backup rest/socket services. But, I don't want all of that data to persist in memory when not being used which is 99% of the time. And when it is being used, I don't mind paying the penalty of having to retrieve it from storage each time.
But, I don't currently see how this can be done without major changes to the current implementation, mainly the fact that
service.store
is expected to be persistent and developer may be using it in their own code.I do have one idea, which is to set the store to null when flushing. But that would break expected behavior of
service.store
always being available (or at least after the first service call, which is weird DX also)This is untested, but is pretty simple and slick. It does break the guarantee that
service.store
stays defined, but that is already a bit weird becauseservice.store
is not defined until after the first service call anyway. So breaking that guarantee (behind theoptions.strict
flag) doesn't seem that bad.I am happy to open a PR to add this and some tests, docs etc. But, this is a bit of
The text was updated successfully, but these errors were encountered: