diff --git a/lib/util/cache/package/decorator.ts b/lib/util/cache/package/decorator.ts index 3a355090a82960..3de488f59c5ccc 100644 --- a/lib/util/cache/package/decorator.ts +++ b/lib/util/cache/package/decorator.ts @@ -1,5 +1,4 @@ import is from '@sindresorhus/is'; -import { logger } from '../../../logger'; import * as packageCache from '.'; type Handler = (parameters: DecoratorParameters) => Promise; @@ -90,37 +89,32 @@ export function cache({ ttlMinutes = 30, }: CacheParameters): Decorator { return decorate(async ({ args, instance, callback }) => { - try { - let finalNamespace: string; - if (is.string(namespace)) { - finalNamespace = namespace; - } else if (is.function_(namespace)) { - finalNamespace = namespace.apply(instance, args); - } - - let finalKey: string; - if (is.string(key)) { - finalKey = key; - } else if (is.function_(key)) { - finalKey = key.apply(instance, args); - } - - const cachedResult = await packageCache.get( - finalNamespace, - finalKey - ); - - if (cachedResult !== undefined) { - return cachedResult; - } - - const result = await callback(); - - await packageCache.set(finalNamespace, finalKey, result, ttlMinutes); - return result; - } catch (err) /* istanbul ignore next */ { - logger.error({ err }, 'cache decorate error'); - throw err; + let finalNamespace: string; + if (is.string(namespace)) { + finalNamespace = namespace; + } else if (is.function_(namespace)) { + finalNamespace = namespace.apply(instance, args); } + + let finalKey: string; + if (is.string(key)) { + finalKey = key; + } else if (is.function_(key)) { + finalKey = key.apply(instance, args); + } + + const cachedResult = await packageCache.get( + finalNamespace, + finalKey + ); + + if (cachedResult !== undefined) { + return cachedResult; + } + + const result = await callback(); + + await packageCache.set(finalNamespace, finalKey, result, ttlMinutes); + return result; }); }