Repository navigation
fix(rest-client): cache fetched catalog for the session - #65
Open
Akil-Dikshan wants to merge 1 commit into
Open
Akil-Dikshan wants to merge 1 commit into
Akil-Dikshan wants to merge 1 commit into
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Comment |
14 of 32 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Every page click, sort change and re-render re-entered
searchPackageswith the same filters, and on the full-fetch path (which the default sort,pullCount-desc, already takes) each one re-ran the entire count + 500-item-batch fetch against Central just to slice a different page. This matched the reported "10-12s first load, ~26s for a deep-linked search, 3 Central requests per page click" behavior.This adds a session cache for the full-fetch path's merged/deduped/filtered catalog, keyed by what actually changes Central's request (
query,areas,vendors,types,orgName) — deliberately not bysort,offsetorlimit, which are applied in memory on every call. In-flight promises are cached too, so concurrent callers share one fetch, and a failed fetch evicts its own entry so the next call retries instead of reusing the failure.Type of Change
Related Issue(s)
Relates to wso2/product-integrator#<ISSUE_NUMBER>
Changes Made
fetchedCatalogCache) following the existingrankingDataCache/hiddenCountCachepattern, with a 12-minute TTL.excludeHidden/filterByExactKeywords/filterByRelevancelogic fromsearchPackagesintofetchCatalog, now called throughgetFetchedCatalog, which checks the cache before fetching.pullCount-descsort, so cached order (which decides tie-breaking) doesn't depend on which sort happened to trigger the first fetch —sortMergedPackagesstill re-sorts a copy of the cached array on every call.__resetFetchedCatalogCacheForTests(), called inbeforeEachofrest-client.test.ts.areas/vendors/typesarrays are sorted before joining, so equivalent requests (reordered filters, padded whitespace) hit the same entry.Known pre-existing issue, out of scope:
getTotalHiddenCount's own cache never evicts on a rejected fetch, so a failed hidden-count fetch stays cached for the session. Not fixed here — flagging for a separate issue.Testing Performed
Test Environment
fetch, not a real browserTest Cases
npm test) — 6 suites, 107 tests (baseline: 6 suites, 102 tests)New tests (describe block in
rest-client.test.ts):All 18 existing
rest-client.test.tstests pass unchanged; only the import and abeforeEachreset call were added to that part of the file.Screenshots
Before
Not applicable — this is a request-count/timing change, not a visual one.
After
Not applicable.
Code Quality Checklist
npm run lintpasses)npm run format:checkpasses)npx tsc --noEmit)Documentation
Performance Impact
Details: Eliminates redundant full-catalog fetches from Central on every page click and sort change within a session. Real-world timing (the reported 10-12s/26s figures) hasn't been re-measured against Central after this change — flagging as a gap, not a claimed number.
Breaking Changes
Additional Notes
fix/sort-full-catalog(3a), which widens which sorts trigger the full-fetch path — that PR is a draft until this one merges.Reviewer Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.