{"version":3,"sources":["../../src/cache/adapters/base.ts"],"sourcesContent":["import { Instance } from '../../instance'\n\nexport abstract class Cache {\n\tabstract set(key: string, data: string, ttlInSecs?: number): Promise<void>\n\tabstract get(key: string): Promise<string | null>\n\tabstract delete(key: string): Promise<void>\n\n\tgetScopedKey(key: string) {\n\t\treturn Instance.get().getScopedName(key, ':')\n\t}\n\n\tasync getOrSet<T>(key: string, fn: () => Promise<T>, ttlInSecs?: number): Promise<T> {\n\t\tconst cached = await this.get(key)\n\t\tif (cached) return JSON.parse(cached) as T\n\n\t\tconst result = await fn()\n\t\tawait this.set(key, JSON.stringify(result), ttlInSecs)\n\t\treturn result\n\t}\n}\n"],"mappings":"6CAEO,IAAeA,EAAf,KAAqB,CAK3B,aAAaC,EAAa,CACzB,OAAOC,EAAS,IAAI,EAAE,cAAcD,EAAK,GAAG,CAC7C,CAEA,MAAM,SAAYA,EAAaE,EAAsBC,EAAgC,CACpF,IAAMC,EAAS,MAAM,KAAK,IAAIJ,CAAG,EACjC,GAAII,EAAQ,OAAO,KAAK,MAAMA,CAAM,EAEpC,IAAMC,EAAS,MAAMH,EAAG,EACxB,aAAM,KAAK,IAAIF,EAAK,KAAK,UAAUK,CAAM,EAAGF,CAAS,EAC9CE,CACR,CACD","names":["Cache","key","Instance","fn","ttlInSecs","cached","result"]}