const cacheFuncs = {};
// ...get script
cacheFuncs[funcName] = {
updateTime: Date.now(),
script,
};// cache time: 60 sec
const cacheFunc = cacheFuncs[cacheKey];
if (cacheFunc && (Date.now() - cacheFunc.updateTime) <= 60000) {
const sandbox = { /*...*/ }
vm.createContext(sandbox);
cacheFunc.script.runInContext(sandbox);
const data = await saandbox.promise;
return data;
} else {
// renew cache
}









