- Bug:
CacheStore.set()incorrectly deleted parsed key arrays immediately after caching them, forcing redundant re-parsing on every subsequent invalidation - Bug: Duplicate
keyArrays.delete(key)call instartGcTimercleanup - Test: Timestamp race condition in security test for corrupted cache keys
- Test: Set Vitest environment to
jsdomglobally so DOM-dependent tests run correctly
matchesKey()now uses reference equality fast-path (===) before falling back toJSON.stringifycomparison — significantly faster for string/number key segments
- Added
main,module,importexport condition,sideEffects: false,engines,keywords,homepage,repository,bugs, andauthorfields topackage.json - Included
README.md,LICENSE, andCHANGELOG.mdin published packagefiles - Version bumped to
0.1.3
cache.dehydrate()— serialize cache to a JSON-safe snapshot for SSRcache.rehydrate(state)— seed client cache from server snapshot; prevents loading flashDehydratedStatetype exported from public API- Global
onErrorhook onCacheConfig— fires once after all retries exhausted (queries pass key array, mutations pass[]) retrynow accepts(failureCount: number, error: Error) => booleanin addition tonumber— allows skipping retries on 401/404timeoutonCacheConfigandQueryConfig— aborts fetch after N ms; each retry attempt gets a fresh timeoutonEventhook onCacheConfig— typed event bus for all cache lifecycle eventsCacheEventdiscriminated union exported from public API:fetch:start,fetch:success,fetch:error,invalidate,set,gc,rehydrate- Per-query
retryandtimeoutoverrides onQueryConfig
cache.mutate()— reactive mutation with optimistic update support (onMutate,onSuccess,onError,onSettled)cache.invalidate(key)— prefix-based cache invalidationcache.prefetch(config)— populate cache without creating a reactive result; deduplicates concurrent prefetchescache.getQueryData(key)/cache.setQueryData(key, data)— direct cache read/writecache.cancelQuery(key)— abort in-flight request- Reactive keys —
key: () => ['todos', userId]re-runs query when dependencies change selecttransform —cache.query<Todo[], ActiveTodo[]>({ select: ... })keepPreviousData— show stale data during key transitionsrefetchOnReconnect— refetch stale queries on network reconnect- Exponential backoff on retry (capped at 30s)
gcTime— prune inactive cache entries after configurable idle period (default 5 min)- Request deduplication for concurrent identical queries
createCache()factory with global configcache.query()returning reactive object with status discriminantstatus:'idle' | 'loading' | 'refreshing' | 'success' | 'error'data,error,isStale,refetch()staleTime,refetchInterval,refetchOnWindowFocus,enabledenabledaccepts getter function for reactive dependent queries- Retry with linear backoff (300ms * attempt)
- Optional
localStoragepersistence - Works in
.svelte,.svelte.ts, and.tsfiles