perf(config): skip redundant schema and session-store work

This commit is contained in:
Peter Steinberger
2026-03-02 20:18:47 +00:00
parent fb5d8a9cd1
commit 2937fe0351
6 changed files with 143 additions and 10 deletions

View File

@@ -133,6 +133,7 @@ export abstract class MemoryManagerSyncOps {
string,
{ lastSize: number; pendingBytes: number; pendingMessages: number }
>();
private lastMetaSerialized: string | null = null;
protected abstract readonly cache: { enabled: boolean; maxEntries?: number };
protected abstract db: DatabaseSync;
@@ -1166,22 +1167,30 @@ export abstract class MemoryManagerSyncOps {
| { value: string }
| undefined;
if (!row?.value) {
this.lastMetaSerialized = null;
return null;
}
try {
return JSON.parse(row.value) as MemoryIndexMeta;
const parsed = JSON.parse(row.value) as MemoryIndexMeta;
this.lastMetaSerialized = row.value;
return parsed;
} catch {
this.lastMetaSerialized = null;
return null;
}
}
protected writeMeta(meta: MemoryIndexMeta) {
const value = JSON.stringify(meta);
if (this.lastMetaSerialized === value) {
return;
}
this.db
.prepare(
`INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value=excluded.value`,
)
.run(META_KEY, value);
this.lastMetaSerialized = value;
}
private resolveConfiguredSourcesForMeta(): MemorySource[] {