blob: 9ee08c84782ad7ca97e8c97bfb49e4b279154926 [file] [log] [blame]
Michael Landoed64b5e2017-06-09 03:19:04 +03001'use strict';
2import {Dictionary} from "app/utils";
3
4interface ICacheService {
5 get(key:string):any;
6 set(key:string, value:any):void;
7}
8
9export 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}