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

LRU implementation with hashmap and doubly linked list #701

Closed
wants to merge 2 commits into from

Conversation

kuldeepsinghborana
Copy link

No description provided.

Copy link

netlify bot commented Feb 19, 2024

Deploy Preview for reselect-docs canceled.

Name Link
🔨 Latest commit af114da
🔍 Latest deploy log https://app.netlify.com/sites/reselect-docs/deploys/65d39e469dc6de0008edd250

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@EskiMojo14
Copy link
Contributor

this doesn't seem to use the equality function?

@kuldeepsinghborana
Copy link
Author

this doesn't seem to use the equality function?

@EskiMojo14 Yes, the equality function can not be used with a hashmap, we need to iterate throgh the all values which will not give us any advantage our the existing memoiser

@markerikson
Copy link
Contributor

@kuldeepsinghborana yeah, that's a problem, and that's what i was pointing to in the issue thread. We rely on equality checks, not a single key.

@kuldeepsinghborana
Copy link
Author

@markerikson @EskiMojo14 @aryaemami59
Can we create a new memoizer that takes a keyGen (key generator) function as an argument? The default keyGen function would convert the supplied argument into a JSON string. Subsequently, our cache Map would utilize this string as a key.

To enhance predictability in the JSON string, we can implement key sorting, ensuring that keys are consistently ordered for every object.

@markerikson
Copy link
Contributor

@kuldeepsinghborana no, just converting values into a string is potentially very expensive. Imagine doing a JSON.stringify() on the entire Redux state for a large app.

@markerikson
Copy link
Contributor

markerikson commented Feb 21, 2024

array.join() isn't going to help either. {a: 1} and {a: 2} are both going to stringify to "[object Object]", which is not unique.

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.

3 participants