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

wip: cache site version info to avoid redundant requests #6048

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Nov 1, 2024

cache site version info to avoid redundant requests

This change introduces a cache for the site version information to avoid redundant requests to the Sourcegraph API. The cache is cleared when the server endpoint changes.

The key aspects of this change are:

  • Maintain a versionInfo property to store the site version information promise per server endpoint
  • Fetch the site version information from the cache if available, otherwise make the API request and store the promise in the cache
  • Expose a getVersionInfo method to retrieve the cached or fetched site version information
  • Update the isSiteVersionValid method to use the cached version information

The benefits of this approach:

  • Single source of truth for version information

  • Cleaner cache invalidation logic

  • Fewer API calls

  • More efficient version checking

  • Simpler code maintenance

  • Consistent version information across all methods

  • Test plan

Check the output channel to see if we are sending request for getting site version

Changelog

This change introduces a cache for the site version to avoid redundant requests to the Sourcegraph API. The cache is cleared when the server endpoint changes.

The key aspects of this change are:

- Maintain a `siteVersionCache` map to store the site version promise per server endpoint
- Subscribe to config changes to clear the cache when the server endpoint changes
- Fetch the site version from the cache if available, otherwise make the API request and store the promise in the cache
This change introduces a cache for the site version information to avoid redundant requests to the Sourcegraph API. The cache is cleared when the server endpoint changes.

The key aspects of this change are:

- Maintain a `versionInfo` property to store the site version information promise per server endpoint
- Fetch the site version information from the cache if available, otherwise make the API request and store the promise in the cache
- Expose a `getVersionInfo` method to retrieve the cached or fetched site version information
- Update the `isSiteVersionValid` method to use the cached version information
@abeatrix abeatrix changed the title cache site version info to avoid redundant requests wip: cache site version info to avoid redundant requests Nov 1, 2024
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