ng-data-cache

1.0.2 • Public • Published

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

Function Description
setData(id: string, data: any): void Save 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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    2
  • 1.0.1
    0
  • 1.0.0
    0
  • 0.0.1
    1

Package Sidebar

Install

npm i ng-data-cache

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

7.82 kB

Total Files

15

Last publish

Collaborators

  • bncunha