@smartico/public-api 0.0.201 → 0.0.202

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  declare class NodeCache {
2
- private static ttlChecker;
3
- private static cache;
2
+ private ttlChecker;
3
+ private cache;
4
4
  constructor();
5
5
  get(key: string): any;
6
6
  set(key: string, value: any, ttlSeconds?: number): void;
package/dist/index.js CHANGED
@@ -496,14 +496,17 @@ exports.SAWGameLayout = void 0;
496
496
 
497
497
  var NodeCache = /*#__PURE__*/function () {
498
498
  function NodeCache() {
499
- if (NodeCache.ttlChecker === undefined) {
500
- NodeCache.ttlChecker = setInterval(function () {
499
+ var _this = this;
500
+ this.ttlChecker = void 0;
501
+ this.cache = {};
502
+ if (this.ttlChecker === undefined) {
503
+ this.ttlChecker = setInterval(function () {
501
504
  var now = new Date().getTime();
502
- for (var key in NodeCache.cache) {
503
- if (NodeCache.cache.hasOwnProperty(key)) {
504
- var o = NodeCache.cache[key];
505
+ for (var key in _this.cache) {
506
+ if (_this.cache.hasOwnProperty(key)) {
507
+ var o = _this.cache[key];
505
508
  if (o.ttl < now) {
506
- delete NodeCache.cache[key];
509
+ delete _this.cache[key];
507
510
  }
508
511
  }
509
512
  }
@@ -512,7 +515,7 @@ var NodeCache = /*#__PURE__*/function () {
512
515
  }
513
516
  var _proto = NodeCache.prototype;
514
517
  _proto.get = function get(key) {
515
- var o = NodeCache.cache[key];
518
+ var o = this.cache[key];
516
519
  if (o !== undefined && o.ttl > new Date().getTime()) {
517
520
  return o.value;
518
521
  }
@@ -521,23 +524,25 @@ var NodeCache = /*#__PURE__*/function () {
521
524
  if (ttlSeconds === void 0) {
522
525
  ttlSeconds = 60;
523
526
  }
524
- NodeCache.cache[key] = {
527
+ this.cache[key] = {
525
528
  value: value,
526
529
  ttl: new Date().getTime() + ttlSeconds * 1000
527
530
  };
528
531
  };
529
532
  _proto.remove = function remove(key) {
530
- if (NodeCache.cache.hasOwnProperty(key)) {
531
- delete NodeCache.cache[key];
533
+ if (this.cache.hasOwnProperty(key)) {
534
+ delete this.cache[key];
532
535
  }
533
536
  };
534
537
  _proto.flushAll = function flushAll() {
535
- NodeCache.cache = {};
538
+ this.cache = {};
539
+ if (this.ttlChecker) {
540
+ clearInterval(this.ttlChecker);
541
+ this.ttlChecker = undefined;
542
+ }
536
543
  };
537
544
  return NodeCache;
538
545
  }();
539
- NodeCache.ttlChecker = void 0;
540
- NodeCache.cache = {};
541
546
 
542
547
  exports.ECacheContext = void 0;
543
548
  (function (ECacheContext) {
@@ -616,6 +621,11 @@ var OCache = /*#__PURE__*/function () {
616
621
  OCache.clearAll = function clearAll() {
617
622
  try {
618
623
  var _this3 = this;
624
+ for (var cacheContext in _this3.cache) {
625
+ if (_this3.cache.hasOwnProperty(cacheContext)) {
626
+ _this3.cache[cacheContext].flushAll();
627
+ }
628
+ }
619
629
  _this3.cache = {};
620
630
  return Promise.resolve();
621
631
  } catch (e) {