MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / memoizedRead

Method memoizedRead

src/db/queries.ts:649–660  ·  view source on GitHub ↗

* `compute()`'s answer, reused until the database changes (see * getChangeStamp), or null inside a transaction, where a rollback could * leave a stale answer under an unchanged stamp: the caller then reads the * database directly, as it did before the memo.

(key: string, compute: () => T)

Source from the content-addressed store, hash-verified

647 * database directly, as it did before the memo.
648 */
649 private memoizedRead<T>(key: string, compute: () => T): T | null {
650 if (this.db.inTransaction !== false) {
651 this.readMemos.delete(key);
652 return null;
653 }
654 const stamp = this.getChangeStamp();
655 const memo = this.readMemos.get(key);
656 if (memo?.stamp === stamp) return memo.value as T;
657 const value = compute();
658 this.readMemos.set(key, { stamp, value });
659 return value;
660 }
661
662 private edgeKindStmt(sql: string): SqliteStatement {
663 let stmt = this.edgeKindStmts.get(sql);

Callers 4

searchNodesLikeMethod · 0.95
fuzzyNamesMethod · 0.95
loweredNodePathsMethod · 0.95

Calls 5

getChangeStampMethod · 0.95
computeFunction · 0.85
deleteMethod · 0.65
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected