Skip to content

Commit

Permalink
Update src/lru-store.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Norman Rzepka <code@normanrz.com>
  • Loading branch information
manzt and normanrz committed Jul 15, 2024
1 parent a6b7281 commit 5d8d635
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lru-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ export function lru<S extends Readable>(store: S, maxSize: number = 100) {
return result;
}
if (getRange) {
const _getRange = getRange;
getRange = (...args: Parameters<NonNullable<S['getRange']>>) => {
const [key, range, opts] = args;
const cacheKey = normalizeKey(key, range);
const cached = cache.get(cacheKey);
if (cached) return cached;
const result = Promise.resolve(getRange!(key, range, opts)).catch((err) => {
const result = Promise.resolve(_getRange!(key, range, opts)).catch((err) => {
cache.delete(cacheKey);
throw err;
});
Expand Down

0 comments on commit 5d8d635

Please sign in to comment.