import { Injectable } from '@angular/core' ; export interface StrategyCache { [ key ] : any ; } @ Injectable ( { providedIn : 'root' } ) export class StrategyCacheService { protected caches : { [ name ] : StrategyCache ; } = { } ; get ( strategyName , key ) { return this . getCacheStore ( strategyName ) [ key ] ; } set ( strategyName , key , value ) { this . getCacheStore ( strategyName ) [ key ] = value ; } del ( strategyName , key ) { delete this . getCacheStore ( strategyName ) [ key ] ; } clear ( strategyName ) { this . caches [ strategyName ] = { } as StrategyCache ; } protected getCacheStore ( strategyName ) { if ( strategyName in this . caches ) return this . caches [ strategyName ] ; return this . caches [ strategyName ] = { } as StrategyCache ; } }