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

Fix LRU cache not updating touched keys #2693

Merged
merged 1 commit into from
Sep 5, 2024
Merged

Conversation

kyscott18
Copy link
Contributor

@kyscott18 kyscott18 commented Sep 5, 2024

The LRU algorithm in utils/lru.ts does not update touched keys, it instead is acting like a "first recently used" algorithm.


PR-Codex overview

This PR focuses on fixing the LRU algorithm in LruMap by updating touched keys.

Detailed summary

  • Updated LruMap to properly update touched keys in the LRU algorithm.
  • Added an override get method to handle key updates.
  • Added a test case to ensure touched keys are updated correctly.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

changeset-bot bot commented Sep 5, 2024

🦋 Changeset detected

Latest commit: 48e179a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Sep 5, 2024

@kyscott18 is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@jxom jxom merged commit 764f259 into wevm:main Sep 5, 2024
2 of 3 checks passed
override get(key: string) {
const value = super.get(key)

if (value !== undefined) {
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious if this should use super.has(key) instead to account for LruMap<undefined>?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah probably better

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