MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / isEntryStale

Function isEntryStale

cli/src/hooks/use-activity-query.ts:114–131  ·  view source on GitHub ↗
(key: string, staleTime: number)

Source from the content-addressed store, hash-verified

112 * Exported for testing purposes.
113 */
114export function isEntryStale(key: string, staleTime: number): boolean {
115 const entry = getCacheEntry(key)
116 if (!entry) return true
117
118 // If we have successful data, use its timestamp for staleness
119 if (entry.dataUpdatedAt !== 0) {
120 return staleTime === 0 || Date.now() - entry.dataUpdatedAt > staleTime
121 }
122
123 // No successful data - check if we have a recent error
124 // Use errorUpdatedAt to prevent rapid retries on persistent errors
125 if (entry.errorUpdatedAt !== null) {
126 return staleTime === 0 || Date.now() - entry.errorUpdatedAt > staleTime
127 }
128
129 // No data and no error timestamp - entry is stale
130 return true
131}
132
133function setQueryFetching(key: string, fetching: boolean): void {
134 const wasFetching = cache.fetchingKeys.has(key)

Callers 3

useActivityQueryFunction · 0.85
tickFunction · 0.85

Calls 1

getCacheEntryFunction · 0.85

Tested by

no test coverage detected