(key: string, value: string)
| 89 | * stored, and undefined is returned. |
| 90 | */ |
| 91 | private setTimeStampedValue(key: string, value: string): TimeStampedData { |
| 92 | if (!key) { |
| 93 | throw new Error("key must be a non-empty string, but was: " + key); |
| 94 | } |
| 95 | |
| 96 | if (!value) { |
| 97 | return undefined; |
| 98 | } |
| 99 | |
| 100 | let valueAsJson: any; |
| 101 | try { |
| 102 | valueAsJson = JSON.parse(value); |
| 103 | } catch (e) { |
| 104 | return undefined; |
| 105 | } |
| 106 | |
| 107 | let timeStampedValue: TimeStampedData = { data: valueAsJson, lastUpdated: Date.now() }; |
| 108 | this.cache.setValue(key, JSON.stringify(timeStampedValue)); |
| 109 | |
| 110 | return timeStampedValue; |
| 111 | } |
| 112 | } |
no test coverage detected