| @@ 1-25 (lines=25) @@ | ||
| 1 | "use strict"; |
|
| 2 | Object.defineProperty(exports, "__esModule", { value: true }); |
|
| 3 | var Cache = /** @class */ (function () { |
|
| 4 | function Cache(cacheItem, timer) { |
|
| 5 | this.cacheItem = cacheItem; |
|
| 6 | this.timer = (timer * 1000); |
|
| 7 | this.timeCached = (new Date()).getTime(); |
|
| 8 | } |
|
| 9 | Cache.prototype.get = function () { |
|
| 10 | if ((this.timeCached + this.timer) < (new Date()).getTime()) { |
|
| 11 | this.cacheItem = null; |
|
| 12 | this.timeCached = null; |
|
| 13 | return null; |
|
| 14 | } |
|
| 15 | else { |
|
| 16 | return this.cacheItem; |
|
| 17 | } |
|
| 18 | }; |
|
| 19 | Cache.prototype.refresh = function (cacheItem) { |
|
| 20 | this.timeCached = (new Date()).getTime(); |
|
| 21 | this.cacheItem = cacheItem; |
|
| 22 | }; |
|
| 23 | return Cache; |
|
| 24 | }()); |
|
| 25 | exports.Cache = Cache; |
|
| 26 | //# sourceMappingURL=cache.js.map |
|
| @@ 1-23 (lines=23) @@ | ||
| 1 | var Cache = /** @class */ (function () { |
|
| 2 | function Cache(cacheItem, timer) { |
|
| 3 | this.cacheItem = cacheItem; |
|
| 4 | this.timer = (timer * 1000); |
|
| 5 | this.timeCached = (new Date()).getTime(); |
|
| 6 | } |
|
| 7 | Cache.prototype.get = function () { |
|
| 8 | if ((this.timeCached + this.timer) < (new Date()).getTime()) { |
|
| 9 | this.cacheItem = null; |
|
| 10 | this.timeCached = null; |
|
| 11 | return null; |
|
| 12 | } |
|
| 13 | else { |
|
| 14 | return this.cacheItem; |
|
| 15 | } |
|
| 16 | }; |
|
| 17 | Cache.prototype.refresh = function (cacheItem) { |
|
| 18 | this.timeCached = (new Date()).getTime(); |
|
| 19 | this.cacheItem = cacheItem; |
|
| 20 | }; |
|
| 21 | return Cache; |
|
| 22 | }()); |
|
| 23 | export { Cache }; |
|
| 24 | //# sourceMappingURL=cache.js.map |
|