OwenKelvin/Angular-School-Management-System

View on GitHub
src/app/core/services/http-cache/http-cache.service.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { Injectable } from '@angular/core';
import { HttpResponse } from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class HttpCacheService {
  private requests: any = {};
  constructor() { }
  put(url: string, response: HttpResponse<any>): void {
    this.requests[url] = response;
  }
  get(url: string): HttpResponse<any> | undefined {
    return this.requests[url];
  }
  invalidateUrl(url: string): void {
    this.requests[url] = undefined;
  }
  invalidateCache(): void {
    this.requests = {};
  }
}