Downgrade to v13
[vi] cảm giác đau khổ
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const DataManager = require('./DataManager');
|
||||
const { _cleanupSymbol } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Manages the API methods of a data model with a mutable cache of instances.
|
||||
@@ -13,6 +14,19 @@ class CachedManager extends DataManager {
|
||||
|
||||
Object.defineProperty(this, '_cache', { value: this.client.options.makeCache(this.constructor, this.holds) });
|
||||
|
||||
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}, ` +
|
||||
`which had a ${this._cache.constructor.name} of ${this.holds.name}.`,
|
||||
name: this.constructor.name,
|
||||
});
|
||||
}
|
||||
|
||||
if (iterable) {
|
||||
for (const item of iterable) {
|
||||
this._add(item);
|
||||
|
||||
Reference in New Issue
Block a user