Skip to content

Merge branch releases/maplru into release#298

Merged
Hanssen0 merged 2 commits intoreleasefrom
releases/maplru
Aug 29, 2025
Merged

Merge branch releases/maplru into release#298
Hanssen0 merged 2 commits intoreleasefrom
releases/maplru

Conversation

@Hanssen0
Copy link
Member

@changeset-bot
Copy link

changeset-bot bot commented Aug 29, 2025

⚠️ No Changeset found

Latest commit: 4122d09

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@netlify
Copy link

netlify bot commented Aug 29, 2025

Deploy Preview for liveccc ready!

Name Link
🔨 Latest commit 4122d09
🔍 Latest deploy log https://app.netlify.com/projects/liveccc/deploys/68b173d9f4481000083f7b3e
😎 Deploy Preview https://deploy-preview-298--liveccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 8 (no change from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Aug 29, 2025

Deploy Preview for docsccc ready!

Name Link
🔨 Latest commit 4122d09
🔍 Latest deploy log https://app.netlify.com/projects/docsccc/deploys/68b173d9c45fef000867e164
😎 Deploy Preview https://deploy-preview-298--docsccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 76 (🟢 up 27 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Aug 29, 2025

Deploy Preview for appccc ready!

Name Link
🔨 Latest commit 4122d09
🔍 Latest deploy log https://app.netlify.com/projects/appccc/deploys/68b173d9ce25aa0008718e2f
😎 Deploy Preview https://deploy-preview-298--appccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 61 (🟢 up 1 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@Hanssen0 Hanssen0 merged commit cc55944 into release Aug 29, 2025
12 of 15 checks passed
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @Hanssen0, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the stability and reliability of the core caching infrastructure within the project. It includes a significant refactor of the Least Recently Used (LRU) cache, which resolves a critical bug, and introduces new tests to validate the cache's behavior. Additionally, it propagates these core updates across the entire codebase through routine version synchronization.

Highlights

  • LRU Cache Refactor and Bug Fix: The core LRU cache implementation (MapLru) has been refactored for improved correctness and robustness, specifically addressing an issue where ClientCacheMemory.findCells could get stuck in an infinite loop.
  • Enhanced Test Coverage: New and comprehensive unit tests have been added for both the MapLru cache and the ClientCacheMemory to ensure the reliability and proper functioning of the caching mechanisms.
  • Cascading Version Updates: Multiple dependent packages across the monorepo have received version bumps to align with the updated @ckb-ccc/core package, ensuring compatibility and leveraging the latest improvements.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Hanssen0 Hanssen0 deleted the releases/maplru branch August 29, 2025 09:33
@netlify
Copy link

netlify bot commented Aug 29, 2025

Deploy Preview for apiccc ready!

Name Link
🔨 Latest commit 4122d09
🔍 Latest deploy log https://app.netlify.com/projects/apiccc/deploys/68b173d9f4481000083f7b42
😎 Deploy Preview https://deploy-preview-298--apiccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 81 (🔴 down 7 from production)
Accessibility: 90 (no change from production)
Best Practices: 92 (no change from production)
SEO: 82 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request primarily refactors the MapLru implementation to be more robust and to fix a potential infinite loop in ClientCacheMemory.findCells. The new implementation separates storage from LRU logic, which is a good pattern. It also adds comprehensive tests for the new MapLru and for ClientCacheMemory.

My review includes one suggestion to improve code clarity by adding explicit return types to the methods in MapLru for consistency. Overall, the changes are a significant improvement.

Comment on lines +171 to +223
override get(key: K) {
if (!super.has(key)) {
return undefined;
return;
}

const value = super.get(key) as V;
this.lru.delete(key);
this.lru.add(key);

// Move to most-recently-used position
super.delete(key);
super.set(key, value);

return value;
return super.get(key);
}

/**
* Inserts a new value into the cache, or updates an existing value.
*
* If the key is already present in the cache, it is first deleted so that the re-insertion
* moves it to the most-recently-used position.
* If the cache is over capacity after the insertion, the least recently used entry is evicted.
*
* @param key The key of the value to insert or update.
* @param value The value to associate with the key.
* @returns This MapLru instance.
* Adds or updates a key-value pair in the cache and marks the key as recently used.
* If setting a new key causes the cache to exceed its capacity, the least recently used item is evicted.
* @param key - The key of the element to add or update.
* @param value - The value of the element to add or update.
* @returns The `MapLru` instance.
*/
override set(key: K, value: V): this {
// Delete and re-insert to move key to the end (most-recently-used)
super.delete(key);
override set(key: K, value: V) {
super.set(key, value);

// Evict oldest if over capacity
if (super.size > this.capacity) {
const oldestKey = super.keys().next().value!;
super.delete(oldestKey);
}
this.lru.delete(key);
this.lru.add(key);

// Evict the oldest entry if capacity is exceeded.
if (this.lru.size > this.capacity) {
const oldestKey = this.lru.keys().next().value!;
this.delete(oldestKey);
}
return this;
}

/**
* Removes the specified element from the cache.
* @param key - The key of the element to remove.
* @returns `true` if an element in the `MapLru` object existed and has been removed, or `false` if the element does not exist.
*/
override delete(key: K): boolean {
if (!super.delete(key)) {
return false;
}

this.lru.delete(key);
return true;
}

/**
* Removes all key-value pairs from the cache.
*/
override clear() {
super.clear();
this.lru.clear();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better code clarity and to maintain consistency with the overridden Map methods and the delete method in this class, it's a good practice to add explicit return types to the get, set, and clear methods. This makes the method signatures more explicit and self-documenting.

  override get(key: K): V | undefined {
    if (!super.has(key)) {
      return;
    }

    this.lru.delete(key);
    this.lru.add(key);

    return super.get(key);
  }

  /**
   * Adds or updates a key-value pair in the cache and marks the key as recently used.
   * If setting a new key causes the cache to exceed its capacity, the least recently used item is evicted.
   * @param key - The key of the element to add or update.
   * @param value - The value of the element to add or update.
   * @returns The `MapLru` instance.
   */
  override set(key: K, value: V): this {
    super.set(key, value);

    this.lru.delete(key);
    this.lru.add(key);

    // Evict the oldest entry if capacity is exceeded.
    if (this.lru.size > this.capacity) {
      const oldestKey = this.lru.keys().next().value!;
      this.delete(oldestKey);
    }
    return this;
  }

  /**
   * Removes the specified element from the cache.
   * @param key - The key of the element to remove.
   * @returns `true` if an element in the `MapLru` object existed and has been removed, or `false` if the element does not exist.
   */
  override delete(key: K): boolean {
    if (!super.delete(key)) {
      return false;
    }

    this.lru.delete(key);
    return true;
  }

  /**
   * Removes all key-value pairs from the cache.
   */
  override clear(): void {
    super.clear();
    this.lru.clear();
  }

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.

1 participant