MCPcopy
hub / github.com/baidu/amis / getApiCache

Function getApiCache

packages/amis-core/src/utils/api.ts:984–1006  ·  view source on GitHub ↗
(api: ApiObject)

Source from the content-addressed store, hash-verified

982}
983
984export function getApiCache(api: ApiObject): ApiCacheConfig | undefined {
985 // 清理过期cache
986 const now = Date.now();
987 let result: ApiCacheConfig | undefined;
988
989 for (let idx = 0, len = apiCaches.length; idx < len; idx++) {
990 const apiCache = apiCaches[idx];
991
992 if (now - apiCache.requestTime > (apiCache.cache as number)) {
993 apiCaches.splice(idx, 1);
994 len--;
995 idx--;
996 continue;
997 }
998
999 if (isSameApi(api, apiCache)) {
1000 result = apiCache;
1001 break;
1002 }
1003 }
1004
1005 return result;
1006}
1007
1008export function setApiCache(
1009 api: ApiObject,

Callers 1

wrappedFetcherFunction · 0.85

Calls 1

isSameApiFunction · 0.85

Tested by

no test coverage detected