Last active
December 5, 2018 14:08
-
-
Save gorkemyontem/2e5dbfac8158a355968638eadf4441f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { InMemoryCacheService } from './in-memory-cache.service'; | |
export const IN_MEMORY_CACHE_PROVIDERS = [ | |
InMemoryCacheService | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
export let inMemoryCache = {}; | |
@Injectable() | |
export class InMemoryCacheService { | |
public has(key: string): boolean { | |
return inMemoryCache[key] !== null; | |
} | |
public get(key: string): any { | |
return inMemoryCache[key] || null; | |
} | |
public set(key: string, value: any): void { | |
inMemoryCache[key] = value; | |
} | |
public remove(key: string): void { | |
delete inMemoryCache[key]; | |
} | |
public clear(): void { | |
inMemoryCache = {}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment