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

use local storage to save repo accessibility #6193

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hitesh-1997
Copy link
Contributor

@hitesh-1997 hitesh-1997 commented Nov 25, 2024

We are always using in-memory cache for calculating repoVisibility always. But without passing github token, we frequently hit rate limit for querying github api and cached tokens are evicted from in-memory cache when user refresh. This leads to less data logged for the autocomplete. This PR stores the tokens in localStorage instead of in-memory store to cache the repo visibility.

We add the following condition to decide if to set the local storage values:

  1. If the local storage cache data was changed due to updates in the local cache.
  2. Since the updates to local storage can be expensive (disk operation), just to make sure we don't hit the call frequently, a time check is added, which updates the cache only if we pass a certain time compare to the last update. Although this can lead to missing some updates (if the cache was updated, and user closes window) but it should be okay git status change rarely.

Other strategies considered.

  1. Using dispose method, but since the function is not async, main thread does not update the storage at all.

Test plan

  1. CI test cases
  2. Manual Testing: Adding debugger and closing and reopening vscode debug window to see if the cached values are persisted in the local storage.

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