Optimize migrate-email-fields-command (#7035)

Quick follow up to prepare for 0.30 release
This commit is contained in:
Charles Bochet
2024-09-15 13:13:35 +02:00
committed by GitHub
parent f54eea0227
commit 872f52990a
4 changed files with 77 additions and 24 deletions

View File

@ -34,6 +34,16 @@ export class CacheManager<T> {
return value;
}
async clearKey(
cacheKey: CacheKey,
onDelete?: (value: T) => Promise<void> | void,
): Promise<void> {
if (this.cache.has(cacheKey)) {
await onDelete?.(this.cache.get(cacheKey)!);
this.cache.delete(cacheKey);
}
}
async clear(onDelete?: (value: T) => Promise<void> | void): Promise<void> {
for (const value of this.cache.values()) {
await onDelete?.(value);