This commit is contained in:
a 2025-03-02 19:22:21 -06:00
parent d261efaf69
commit a2e39483f2
No known key found for this signature in database
GPG Key ID: 2F22877AA4DFDADB

View File

@ -37,7 +37,7 @@ export class WApi {
await store.delete({key})
},
async set(key, value, req) {
let ttl = value.state === 'loading'
let expireTime = value.state === 'loading'
? Date.now() +
(req?.cache && typeof req.cache.ttl === 'number'
? req.cache.ttl
@ -52,6 +52,12 @@ export class WApi {
: // otherwise, we can't determine when it should expire, so we keep
// it indefinitely.
undefined
let ttl: number | undefined
if(expireTime) {
ttl = expireTime - Date.now()
}
await store.set({
key,
value: JSON.stringify(value),