import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root', }) export class HttpCacheService { cacheMap: Map>> = new Map(); constructor() {} public get_cache(key: string, requestStr: string): Observable | undefined { return this.cacheMap.get(key)?.get(requestStr); } public set_cache(key: string, requestStr: string, value: Observable): void { if (this.cacheMap.get(key)) { this.cacheMap.get(key) ?? new Map().set(requestStr, value); } else { this.cacheMap.set(key, new Map().set(requestStr, value)); } } }