in src/caching/GenericCache.ts [17:41]
public async getOrCreate<T>(
cacheKey: string,
createFunction: () => Promise<T & ICachable & object>,
updateFunction?: (item: T) => Promise<T & ICachable & object>
): Promise<T & ICachable> {
if (updateFunction) {
this.updateFunctions.set(cacheKey, updateFunction);
}
const item = await this.get<T>(cacheKey);
if (item) {
return item;
}
const newCacheItem = await createFunction();
if (!newCacheItem) {
throw new Error("Could not create cache item");
}
if (!isEmptyAccessToken(newCacheItem)) {
this.setCacheItem(cacheKey, newCacheItem);
}
return newCacheItem;
}