MCPcopy Create free account
hub / github.com/opral/inlang / readModuleFromCache

Function readModuleFromCache

packages/sdk/src/plugin/cache.ts:17–34  ·  view source on GitHub ↗
(
	moduleURI: string,
	lix: Lix
)

Source from the content-addressed store, hash-verified

15}
16
17async function readModuleFromCache(
18 moduleURI: string,
19 lix: Lix
20): Promise<string | undefined> {
21 const moduleHash = escape(moduleURI);
22 const filePath = `/cache/plugins/${moduleHash}`;
23
24 const file = await lix.db
25 .selectFrom("file")
26 .where("path", "=", filePath)
27 .selectAll()
28 .executeTakeFirst();
29
30 if (file) {
31 return new TextDecoder().decode(file.data);
32 }
33 return undefined;
34}
35
36async function writeModuleToCache(
37 moduleURI: string,

Callers 1

withCacheFunction · 0.85

Calls 1

escapeFunction · 0.85

Tested by

no test coverage detected