@leordev-web5/api
Version:
SDK for accessing the features and capabilities of Web5
30 lines • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SendCache = void 0;
var SendCache = exports.SendCache = /** @class */ (function () {
function SendCache() {
}
SendCache.set = function (id, target) {
var targetCache = SendCache.cache.get(id) || new Set();
SendCache.cache.delete(id);
SendCache.cache.set(id, targetCache);
if (this.cache.size > SendCache.sendCacheLimit) {
var firstRecord = SendCache.cache.keys().next().value;
SendCache.cache.delete(firstRecord);
}
targetCache.delete(target);
targetCache.add(target);
if (targetCache.size > SendCache.sendCacheLimit) {
var firstTarget = targetCache.keys().next().value;
targetCache.delete(firstTarget);
}
};
SendCache.check = function (id, target) {
var targetCache = SendCache.cache.get(id);
return targetCache ? targetCache.has(target) : false;
};
SendCache.cache = new Map();
SendCache.sendCacheLimit = 100;
return SendCache;
}());
//# sourceMappingURL=send-cache.js.map