({ cacheKey, payload, ttlMs, staleTtlMs, registryKey })
| 502 | } |
| 503 | |
| 504 | async setCacheEntry({ cacheKey, payload, ttlMs, staleTtlMs, registryKey }) { |
| 505 | const createdAt = Date.now(); |
| 506 | const cacheEnvelope = { |
| 507 | payload, |
| 508 | createdAt, |
| 509 | freshUntil: createdAt + ttlMs, |
| 510 | staleUntil: createdAt + staleTtlMs, |
| 511 | }; |
| 512 | |
| 513 | await this.store.set(cacheKey, JSON.stringify(cacheEnvelope), staleTtlMs); |
| 514 | await this.store.hset(registryKey, cacheKey, `${cacheEnvelope.staleUntil}`); |
| 515 | this.debugLog("cache_write", { |
| 516 | cacheKey, |
| 517 | registryKey, |
| 518 | ttlMs, |
| 519 | staleTtlMs, |
| 520 | }); |
| 521 | return cacheEnvelope; |
| 522 | } |
| 523 | |
| 524 | async trackChartVariantUsage({ chartId, variantHash, runtimePayload, weight = 1 }) { |
| 525 | if (!chartId || !variantHash || !runtimePayload?.hasRuntimeFilters) { |
no test coverage detected