Purge cache

This commit is contained in:
Andras Schmelczer 2025-11-16 21:01:18 +00:00
parent 4f582c3279
commit f22e784ee1
3 changed files with 12 additions and 2 deletions

View file

@ -152,7 +152,8 @@ export class SyncClient {
settings, settings,
syncService, syncService,
fileOperations, fileOperations,
unrestrictedSyncer unrestrictedSyncer,
contentCache
); );
const webSocketManager = new WebSocketManager( const webSocketManager = new WebSocketManager(

View file

@ -17,6 +17,7 @@ import { createPromise } from "../utils/create-promise";
import { SyncResetError } from "../services/sync-reset-error"; import { SyncResetError } from "../services/sync-reset-error";
import { Locks } from "../utils/locks"; import { Locks } from "../utils/locks";
import type { DocumentVersionWithoutContent } from "../services/types/DocumentVersionWithoutContent"; import type { DocumentVersionWithoutContent } from "../services/types/DocumentVersionWithoutContent";
import type { FixedSizeDocumentCache } from "../utils/fix-sized-cache";
export class Syncer { export class Syncer {
private readonly remoteDocumentsLock: Locks<DocumentId>; private readonly remoteDocumentsLock: Locks<DocumentId>;
@ -33,7 +34,8 @@ export class Syncer {
settings: Settings, settings: Settings,
private readonly syncService: SyncService, private readonly syncService: SyncService,
private readonly operations: FileOperations, private readonly operations: FileOperations,
private readonly internalSyncer: UnrestrictedSyncer private readonly internalSyncer: UnrestrictedSyncer,
private readonly contentCache: FixedSizeDocumentCache
) { ) {
this.syncQueue = new PQueue({ this.syncQueue = new PQueue({
concurrency: settings.getSettings().syncConcurrency concurrency: settings.getSettings().syncConcurrency
@ -250,6 +252,7 @@ export class Syncer {
public async reset(): Promise<void> { public async reset(): Promise<void> {
await this.waitUntilFinished(); await this.waitUntilFinished();
this.contentCache.clear();
} }
public async syncRemotelyUpdatedFile( public async syncRemotelyUpdatedFile(

View file

@ -54,4 +54,10 @@ export class FixedSizeDocumentCache {
this.currentSizeInBytes -= lruEntry.byteLength; this.currentSizeInBytes -= lruEntry.byteLength;
} }
} }
public clear(): void {
this.cache.clear();
this.usageOrder = [];
this.currentSizeInBytes = 0;
}
} }