
export class CachingService {


    store(key: string, value: any) {
        sessionStorage.setItem(key, JSON.stringify(value));
    }

    read(key: string): any {
        const value = sessionStorage.getItem(key);

        if (!value)
            return '';

        return JSON.parse(value);
    }

    emptyStorage(): void {
        sessionStorage.clear();
    }

    storePersistant(key: string, value: any) {
        localStorage.setItem(key, JSON.stringify(value));
    }

    readPersistant(key: string): any {
        const value = localStorage.getItem(key);

        if (!value)
            return '';

        return JSON.parse(value);
    }
    
}