Skip to content

Commit

Permalink
Caching 20230221 (#390)
Browse files Browse the repository at this point in the history
* prevent cache modification when parallel fetches are waiting on the same resource

* package updates
  • Loading branch information
carrolp authored Feb 21, 2023
1 parent 0fd5359 commit d4821a9
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 122 deletions.
4 changes: 2 additions & 2 deletions lib/FetchEnvs.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module.exports = class FetchEnvs {
// When updating a key, updating it for all users
for( const cacheUser of globalResourceCacheUsers ) {
if( globalResourceCache.has(`${cacheUser}/${cacheKey}`) ) {
globalResourceCache.set(`${cacheUser}/${cacheKey}`, resource);
globalResourceCache.set(`${cacheUser}/${cacheKey}`, clone(resource));
updated = true;
}
}
Expand Down Expand Up @@ -162,7 +162,7 @@ module.exports = class FetchEnvs {
}

// Wait for the outstanding api call to complete, use it's value
resource = await singleResourceQueryCache[cacheKey];
resource = clone( await singleResourceQueryCache[cacheKey] );
}

return resource;
Expand Down
Loading

0 comments on commit d4821a9

Please sign in to comment.