import { Component } from '@angular/core';
import { CacheService } from 'ng2-cache-service';
declare var BUILD_VERSION: string;
@Component({
selector: 'some-selector',
template: '<div>Template</div>',
providers: [ CacheService ]
})
export class ExampleComponent {
constructor(private _cacheService: CacheService) {}
public func() {
this._cacheService.setGlobalPrefix(BUILD_VERSION);
let result: boolean = this._cacheService.set('key', ['some data']);
this._cacheService.set('key', ['some data'], {maxAge: 5 * 60});
this._cacheService.set('key', {'some': 'data'}, {expires: Date.now() + 1000 * 60 * 60});
this._cacheService.set('key', 'some data', {tag: 'tag'});
let data: any|null = this._cacheService.get('key');
let exists: boolean = this._cacheService.exists('key');
this._cacheService.removeTag('tag');
this._cacheService.removeAll();
this._cacheService.getTagData('tag');
}
}