UNPKG

1.06 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var CacheRepo_1 = require("./CacheRepo");
4var CacheThread_1 = require("./CacheThread");
5var CacheInstance = (function () {
6 function CacheInstance(name) {
7 var _this = this;
8 this.repo = new CacheRepo_1.default();
9 this.thread = new CacheThread_1.default();
10 this.nextNodeKey = 0;
11 this.reset = function () {
12 _this.repo = new CacheRepo_1.default();
13 _this.thread = new CacheThread_1.default();
14 _this.nextNodeKey = 0;
15 };
16 this.addNode = function (node) {
17 if (_this.repo.add(node)) {
18 _this.thread.addNode(node.id);
19 _this.nextNodeKey++;
20 return true;
21 }
22 return false;
23 };
24 this.length = function () { return _this.thread.nodes.length; };
25 this.size = function () { return _this.repo.length; };
26 this.name = name;
27 }
28 return CacheInstance;
29}());
30exports.default = CacheInstance;