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

Method memoizedRead

src/db/queries.ts:651–662  ·  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

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