update
This commit is contained in:
@ -146,6 +146,35 @@ export class UnifiedRateLimiter extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the rate limiter and clean up all resources
|
||||
*/
|
||||
public destroy(): void {
|
||||
// Stop the cleanup interval
|
||||
this.stop();
|
||||
|
||||
// Clear all maps to free memory
|
||||
this.counters.clear();
|
||||
this.ipCounters.clear();
|
||||
this.patternCounters.clear();
|
||||
|
||||
// Clear blocks
|
||||
if (this.config.blocks) {
|
||||
this.config.blocks = {};
|
||||
}
|
||||
|
||||
// Clear statistics
|
||||
this.stats = {
|
||||
activeCounters: 0,
|
||||
totalBlocked: 0,
|
||||
currentlyBlocked: 0,
|
||||
byPattern: {},
|
||||
byIp: {}
|
||||
};
|
||||
|
||||
logger.log('info', 'UnifiedRateLimiter destroyed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up expired counters and blocks
|
||||
*/
|
||||
|
Reference in New Issue
Block a user