MCPcopy
hub / github.com/Uniswap/interface / getFetchPolicyForKey

Function getFetchPolicyForKey

src/utils/getFetchPolicyForKey.ts:5–16  ·  view source on GitHub ↗
(key: string, expirationMs: number)

Source from the content-addressed store, hash-verified

3const keys = new Map<string, number>()
4
5export const getFetchPolicyForKey = (key: string, expirationMs: number): WatchQueryFetchPolicy => {
6 const lastFetchTimestamp = keys.get(key)
7 const diffFromNow = lastFetchTimestamp ? Date.now() - lastFetchTimestamp : Number.MAX_SAFE_INTEGER
8 let fetchPolicy: WatchQueryFetchPolicy = 'cache-first'
9
10 if (diffFromNow > expirationMs) {
11 keys.set(key, Date.now())
12 fetchPolicy = 'network-only'
13 }
14
15 return fetchPolicy
16}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…