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

Function writeModuleToCache

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

Source from the content-addressed store, hash-verified

34}
35
36async function writeModuleToCache(
37 moduleURI: string,
38 moduleContent: string,
39 lix: Lix
40): Promise<void> {
41 const moduleHash = escape(moduleURI);
42 const filePath = `/cache/plugins/${moduleHash}`;
43
44 await lix.db
45 .insertInto("file")
46 .values({
47 path: filePath,
48 data: new TextEncoder().encode(moduleContent),
49 })
50 // update the cache
51 .onConflict((oc) =>
52 oc.doUpdateSet({ data: new TextEncoder().encode(moduleContent) })
53 )
54 .execute();
55}
56
57/**
58 * Implements a "Network-First" caching strategy.

Callers 1

withCacheFunction · 0.85

Calls 1

escapeFunction · 0.85

Tested by

no test coverage detected