@leordev-web5/api
Version:
SDK for accessing the features and capabilities of Web5
24 lines • 891 B
JavaScript
export class SendCache {
static set(id, target) {
let targetCache = SendCache.cache.get(id) || new Set();
SendCache.cache.delete(id);
SendCache.cache.set(id, targetCache);
if (this.cache.size > SendCache.sendCacheLimit) {
const firstRecord = SendCache.cache.keys().next().value;
SendCache.cache.delete(firstRecord);
}
targetCache.delete(target);
targetCache.add(target);
if (targetCache.size > SendCache.sendCacheLimit) {
const firstTarget = targetCache.keys().next().value;
targetCache.delete(firstTarget);
}
}
static check(id, target) {
let targetCache = SendCache.cache.get(id);
return targetCache ? targetCache.has(target) : false;
}
}
SendCache.cache = new Map();
SendCache.sendCacheLimit = 100;
//# sourceMappingURL=send-cache.js.map