MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeInMemoryBlobStore

Function makeInMemoryBlobStore

packages/core/sdk/src/blob.ts:134–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132 * `BlobStore` interface.
133 */
134export const makeInMemoryBlobStore = (): BlobStore => {
135 const store = new Map<string, string>();
136 const k = (ns: string, key: string) => `${ns}::${key}`;
137 return {
138 get: (ns, key) => Effect.sync(() => store.get(k(ns, key)) ?? null),
139 getMany: (namespaces, key) =>
140 Effect.sync(() => {
141 const hits = new Map<string, string>();
142 for (const ns of namespaces) {
143 const v = store.get(k(ns, key));
144 if (v !== undefined) hits.set(ns, v);
145 }
146 return hits;
147 }),
148 put: (ns, key, value) =>
149 Effect.sync(() => {
150 store.set(k(ns, key), value);
151 }),
152 delete: (ns, key) =>
153 Effect.sync(() => {
154 store.delete(k(ns, key));
155 }),
156 has: (ns, key) => Effect.sync(() => store.has(k(ns, key))),
157 };
158};
159
160/** Hex SHA-256 of a UTF-8 string — the content-address key plugins use for
161 * write-once blobs (`put(key(hash), …)` is then idempotent and orphaned

Callers 1

blob.test.tsFile · 0.90

Calls 5

kFunction · 0.85
syncMethod · 0.80
setMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected