/** * Write Coalescing 유틸리티 * 실시간 쓰기를 버퍼링하여 배치로 처리하여 I/O 부하를 줄입니다. * * 사용 사례: * - last_accessed_at 업데이트를 초당 1회로 제한 * - recall_count 업데이트를 버퍼링하여 배치 처리 */ export interface CoalescedWrite { /** * 메모리 ID */ memoryId: string; /** * 업데이트할 필드들 */ fields: { recall_count?: number; last_accessed_at?: string; g_value?: number; consolidation_score?: number; }; } /** * Write Coalescing Manager * 메모리 버퍼를 사용하여 쓰기 작업을 결합하고 주기적으로 flush합니다. */ export declare class WriteCoalescingManager { private buffer; private flushInterval; private flushTimer; private isFlushing; private isDestroyed; private flushCallback; /** * @param flushIntervalMs flush 간격 (밀리초, 기본값: 1000ms = 1초) * @param flushCallback flush 시 호출할 콜백 함수 */ constructor(flushIntervalMs: number | undefined, flushCallback: (writes: CoalescedWrite[]) => Promise); /** * 쓰기 작업을 버퍼에 추가 * 동일한 memoryId에 대한 여러 업데이트는 자동으로 병합됩니다. * * @param write 쓰기 작업 */ addWrite(write: CoalescedWrite): void; /** * 여러 쓰기 작업을 한 번에 추가 * * @param writes 쓰기 작업 배열 */ addWrites(writes: CoalescedWrite[]): void; /** * Flush 타이머 시작 */ private startFlushTimer; /** * 버퍼의 모든 쓰기 작업을 즉시 flush * * @returns flush된 쓰기 작업 수 */ flush(): Promise; /** * 버퍼 크기 반환 */ getBufferSize(): number; /** * 버퍼가 비어있는지 확인 */ isEmpty(): boolean; /** * 모든 타이머 정리 및 버퍼 초기화 * 진행 중인 flush 작업이 있으면 완료될 때까지 대기합니다. */ destroy(): Promise; } //# sourceMappingURL=write-coalescing.d.ts.map