MCPcopy
hub / github.com/coder/mux / mutate

Method mutate

src/node/services/memoryMeta.ts:151–163  ·  view source on GitHub ↗

* Read-modify-write cycle under the sidecar mutex. Persists before updating * the in-memory cache so observers never see state that didn't make it to * disk. Entries that end up entirely default are dropped.

(update: (entries: Record<string, MemoryMetaEntry>) => void)

Source from the content-addressed store, hash-verified

149 * disk. Entries that end up entirely default are dropped.
150 */
151 private async mutate(update: (entries: Record<string, MemoryMetaEntry>) => void): Promise<void> {
152 await this.lock.withLock("meta", async () => {
153 const meta = await this.load();
154 const entries = { ...meta.entries };
155 update(entries);
156 for (const [key, entry] of Object.entries(entries)) {
157 if (isEmptyEntry(entry)) delete entries[key];
158 }
159 const next: MemoryMetaFile = { entries };
160 await writeFileAtomic(this.metaPath, JSON.stringify(next, null, 2), { encoding: "utf-8" });
161 this.cache = next;
162 });
163 }
164
165 /** Logical keys of all pinned memory files. */
166 async getPinnedKeys(): Promise<Set<string>> {

Callers 4

setPinnedMethod · 0.95
recordAccessMethod · 0.95
renameKeysMethod · 0.95
removeKeysMethod · 0.95

Calls 4

loadMethod · 0.95
isEmptyEntryFunction · 0.85
withLockMethod · 0.80
updateFunction · 0.50

Tested by

no test coverage detected