MCPcopy Create free account
hub / github.com/GoogleChrome/samples / storeFileInSWCache

Function storeFileInSWCache

mediapipe-llm/script.js:85–104  ·  view source on GitHub ↗
(blob)

Source from the content-addressed store, hash-verified

83};
84
85const storeFileInSWCache = async (blob) => {
86 try {
87 performance.mark('start-sw-cache-cache');
88 const modelCache = await caches.open('models');
89 await modelCache.put('model.bin', new Response(blob));
90 performance.mark('end-sw-cache-cache');
91 const mark = performance.measure(
92 'sw-cache-cache',
93 'start-sw-cache-cache',
94 'end-sw-cache-cache'
95 );
96 console.log(
97 'Model file cached in sw-cache.',
98 mark.name,
99 mark.duration.toFixed(2)
100 );
101 } catch (err) {
102 console.error(err.name, err.message);
103 }
104};
105
106const storeFileHandleInIDB = async (handle) => {
107 try {

Callers 1

script.jsFile · 0.85

Calls 3

openMethod · 0.45
logMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected