1.0.2 • Published 4 years ago

ng-data-cache v1.0.2

Weekly downloads
22
License
MIT
Repository
github
Last release
4 years ago

DataCache

This is a service to manager data in a cache service

Instalation

$ npm install --save ng-data-cache

Quickstart

Inject NgDataCacheService into a component or service that you want to use.

import { Injectable } from '@angular/core';
import { NgDataCacheService } from 'ng-data-cache';

@Injectable({
  providedIn: 'root'
})
export class MyService {

  constructor(private cacheService: NgDataCacheService) { }
}

Save new data in cache

Must pass a key and a data to store.

this.cacheService.setData('MY_KEY', {name: 'Mario'});

Get data saved

Must pass the same key when was save.

this.cacheService.foundData('MY_KEY'); // {name: 'Mario'}

Remove data

Must pass the same key when was save to remove data from cache.

this.cacheService.removeData('MY_KEY');

Clean all cache

this.cacheService.cleanCache();

All functions

FunctionDescription
setData(id: string, data: any): voidSave data in cache in given key.
removeData(id: string): void;Remove data from given key.
foundData(id: string): any;Return data from given key.
getCache(): DataCache[];Return all values stored in cache
cleanCache(): void;Clean all cache