Improve speed of freshness and storage

This commit is contained in:
Jon Staab
2024-09-18 10:11:00 -07:00
parent 315f53e9b2
commit 2b1cb5fa33
3 changed files with 22 additions and 16 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import {readable, derived, type Readable} from 'svelte/store'
import {indexBy, type Maybe, now} from '@welshman/lib'
import {withGetter} from '@welshman/store'
import {getFreshness, setFreshness} from './freshness'
import {getFreshness, setFreshnessThrottled} from './freshness'
export const collection = <T, LoadArgs extends any[]>({
name,
@@ -42,7 +42,7 @@ export const collection = <T, LoadArgs extends any[]>({
loadAttempts.set(key, attempt + 1)
setFreshness(name, key, now())
setFreshnessThrottled({ns: name, key, ts: now()})
const promise = load(key, ...args)