+6
-3
@@ -91,10 +91,12 @@ import { hash } from "ohash"; | ||
| let entry = {}; | ||
| let hitIndex = -1; | ||
| try { | ||
| for (const base of bases) { | ||
| for (let i = 0; i < bases.length; i++) { | ||
| const result = await useStorage().get(_buildCacheKey(key, { | ||
| group, | ||
| name | ||
| }, base)); | ||
| }, bases[i])); | ||
| if (result) { | ||
| entry = result; | ||
| hitIndex = i; | ||
| break; | ||
@@ -150,5 +152,6 @@ } | ||
| } else setOpts = { ttl: opts.maxAge }; | ||
| const writeBases = hitIndex < 0 ? bases : bases.slice(0, hitIndex + 1); | ||
| const promise = (async () => { | ||
| try { | ||
| await Promise.all(bases.map((b) => useStorage().set(_buildCacheKey(key, { | ||
| await Promise.all(writeBases.map((b) => useStorage().set(_buildCacheKey(key, { | ||
| group, | ||
@@ -155,0 +158,0 @@ name |
+1
-1
| { | ||
| "name": "ocache", | ||
| "version": "0.1.3", | ||
| "version": "0.1.4", | ||
| "description": "Standalone caching utilities with TTL, SWR, and HTTP response caching", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
34490
0.4%399
0.76%