refactor: merge collections with keeping entries at max (#6242)

This commit is contained in:
1Computer1
2021-07-31 16:03:58 -04:00
committed by GitHub
parent a25e16599a
commit bb5e648f3d
9 changed files with 209 additions and 170 deletions

View File

@@ -14,14 +14,14 @@ class CachedManager extends DataManager {
Object.defineProperty(this, '_cache', { value: this.client.options.makeCache(this.constructor, this.holds) });
let cleanup = this._cache[_cleanupSymbol];
let cleanup = this._cache[_cleanupSymbol]?.();
if (cleanup) {
cleanup = cleanup.bind(this._cache);
client._cleanups.add(cleanup);
client._finalizers.register(this, {
cleanup,
message:
`Garbage Collection completed on ${this.constructor.name}, ` +
`Garbage collection completed on ${this.constructor.name}, ` +
`which had a ${this._cache.constructor.name} of ${this.holds.name}.`,
name: this.constructor.name,
});