Skip to content
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

Let Ladda return the same object references - immutable cache #41

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

LFDM
Copy link
Collaborator

@LFDM LFDM commented Jul 15, 2018

A current pain point with Ladda IMO is that every cache hit gives you a new reference to a cached object. While this is super-safe and makes it impossible to destroy the cache through mutation, it's also a strange contract - especially given current practices around dealing with immutable objects in e.g. React.

The issue is resolved here.
For backwards compatibility there's a global flag called strict which defaults to true. It performs an Object.freeze on cache objects, so that we can still guarantee that our cache is not unlawfully manipulated.
However, some past users might have violated this rule in the past - strict: false would keep their code alive at least.
In addition the flag can be set to false when you just don't want these safeties - we deep freeze everything. Not sure how freeze performs - probably quite quick - still, adds some overhead.

This was done a while ago already - I think it's time to merge it.

On the branch fix/id-from-args-with-lists I just pushed a seemingly unrelated broken test I discovered earlier. This test would also be fixed by the changes made in this PR.

cc @mlent

@LFDM
Copy link
Collaborator Author

LFDM commented Jul 15, 2018

This change might be a good case to bump to the next major version even.

@mlent
Copy link

mlent commented Jul 15, 2018

@connor-baer @GuyLivni We were hypothesizing that this could be the source of our 'memory leak' that causes the website cache to grow so huge. Can you guys keep an eye on this and have a look once it's released?

@mlent
Copy link

mlent commented Aug 17, 2018

@LFDM Any news on the release 😛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants