diff --git a/src/managers/base.ts b/src/managers/base.ts index 442b7fc..d55a34f 100644 --- a/src/managers/base.ts +++ b/src/managers/base.ts @@ -67,6 +67,20 @@ export class BaseManager { yield* readable.getIterator() } + async fetch(...args: unknown[]): Promise { + return undefined + } + + /** Try to get value from cache, if not found then fetch */ + async resolve(key: string): Promise { + const cacheValue = await this.get(key) + if (cacheValue !== undefined) return cacheValue + else { + const fetchValue = await this.fetch(key).catch(() => undefined) + if (fetchValue !== undefined) return fetchValue + } + } + /** Deletes everything from Cache */ flush(): any { return this.client.cache.deleteCache(this.cacheName)