ng2-cache
ng2-cache copied to clipboard
Default cache options
HI, first off, great package its working well good job!
I noticed your using this for Default cache options.
/** * Default cache options */ private _defaultOptions: CacheOptionsInterface = { expires: Number.MAX_VALUE, maxAge : Number.MAX_VALUE };
How long is that exactly, am i reading it right to say its indefinite until the session cache is cleared?
If so, how would you set the cache to expire to say 1 day?
Hi, thanks :)
//put some data to cache "forever"
//returns true is data was cached successfully, otherwise - false
let result: boolean = this._cacheService.set('key', ['some data']);
//put some data to cache for 5 minutes (maxAge - in seconds)
this._cacheService.set('key', ['some data'], {maxAge: 5 * 60});
//put some data to cache for 1 hour (expires - timestamp with milliseconds)
this._cacheService.set('key', {'some': 'data'}, {expires: Date.now() + 1000 * 60 * 60});
//put some data to cache with tag "tag"
this._cacheService.set('key', 'some data', {tag: 'tag'});
just like in example PS "forever" means - until you didn't clear storage manually