Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame^] | 1 | 'use strict'; |
| 2 | import {Dictionary} from "app/utils"; |
| 3 | |
| 4 | interface ICacheService { |
| 5 | get(key:string):any; |
| 6 | set(key:string, value:any):void; |
| 7 | } |
| 8 | |
| 9 | export class CacheService implements ICacheService { |
| 10 | |
| 11 | private storage:Dictionary<string, any>; |
| 12 | |
| 13 | constructor() { |
| 14 | this.storage = new Dictionary<string, any>(); |
| 15 | }; |
| 16 | |
| 17 | public get = (key:string):any => { |
| 18 | return this.storage.getValue(key); |
| 19 | }; |
| 20 | |
| 21 | public set = (key:string, value:any):void => { |
| 22 | this.storage.setValue(key, value); |
| 23 | }; |
| 24 | |
| 25 | public remove = (key:string):void => { |
| 26 | if (this.storage.containsKey(key)) { |
| 27 | this.storage.remove(key); |
| 28 | } |
| 29 | }; |
| 30 | |
| 31 | public contains = (key:string):boolean => { |
| 32 | return this.storage.containsKey(key); |
| 33 | }; |
| 34 | } |