public async get()

in src/caching/GenericCache.ts [43:71]


    public async get<T>(cacheKey: string): Promise<T & ICachable | null> {
        let asString = this.storage.get(cacheKey);
        let cachedItem: T & ICachable = asString ? JSON.parse(asString) : null;

        if (this.itemDueToExpire(cachedItem) && this.updateFunctions.has(cacheKey)) {
            const updateFunction = this.updateFunctions.get(cacheKey);
            await this.tryUpdateItem(cacheKey, cachedItem, updateFunction!);

            // Ensure updated item is returned
            asString = this.storage.get(cacheKey);
            cachedItem = asString ? JSON.parse(asString) : null;
        }

        if (!cachedItem) {
            return null;
        }

        if (cachedItem.expires && (cachedItem.expires === -1 || cachedItem.expires <= Date.now())) {
            this.remove(cacheKey);
            return null;
        }

        if (cachedItem.expiresOnAccess && cachedItem.expiresOnAccess === true) {
            this.remove(cacheKey);
            return cachedItem;
        }

        return cachedItem;
    }