MCPcopy Create free account
hub / github.com/OpenSIST/OpenSIST.github.io / beginCacheRequests

Function beginCacheRequests

src/Data/CacheStore.js:138–175  ·  view source on GitHub ↗
(keys, priority = FOREGROUND_PRIORITY, requestEpoch = cacheEpoch)

Source from the content-addressed store, hash-verified

136 await localforage.clear();
137 if (theme) {
138 await localforage.setItem("theme", theme);
139 }
140 if (typeof window !== "undefined") {
141 window.dispatchEvent(new Event(CACHE_CLEARED_EVENT));
142 }
143}
144
145export function getCacheEpoch() {
146 return cacheEpoch;
147}
148
149export function beginCacheRequests(keys, priority = FOREGROUND_PRIORITY, requestEpoch = cacheEpoch) {
150 if (requestEpoch !== cacheEpoch) {
151 return {
152 keys: [],
153 epoch: requestEpoch,
154 versionFor: () => undefined,
155 release() {
156 },
157 };
158 }
159 const isBackground = priority === BACKGROUND_PRIORITY;
160 const requestKeys = isBackground
161 ? keys.filter((key) => !foregroundRequests.has(key))
162 : keys;
163 const versions = new Map(requestKeys.map((key) => [key, nextRequestVersion(key)]));
164 if (!isBackground) {
165 requestKeys.forEach((key) => foregroundRequests.set(key, (foregroundRequests.get(key) ?? 0) + 1));
166 }
167
168 return {
169 keys: requestKeys,
170 epoch: requestEpoch,
171 versionFor: (key) => versions.get(key),
172 release() {
173 if (isBackground) {
174 return;
175 }
176 requestKeys.forEach((key) => {
177 const remaining = (foregroundRequests.get(key) ?? 1) - 1;
178 if (remaining > 0) {

Callers 3

getMetadataBatchFunction · 0.90
getProgramDescsFunction · 0.90
loadCachedValueFunction · 0.85

Calls 1

nextRequestVersionFunction · 0.85

Tested by

no test coverage detected