Google Apps 脚本 - 永久缓存

Sta*_*ica 4 javascript caching google-apps-script

我有一张包含很多自定义函数调用的工作表。我想永久缓存结果。到现在为止,我一直使用缓存服务,但它被限制为六个小时。有没有办法永久缓存结果?我在这里的评论中读到,可以在用户的​​浏览器中缓存数据。我应该如何实现这一目标?

谢谢 !

编辑:感谢 Serge Hendrickx 的建议,我能够使用与缓存服务相同的方法永久缓存结果:

var scriptProperties = PropertiesService.getScriptProperties();

if(getCachedVariable(variableName) == null){
 // Results aren't in cache, get them and save them
 scriptProperties.setProperty(variableName,value);
}
return getCachedVariable(variableName);

function getCachedVariable(variableName){
  return scriptProperties.getProperty(variableName);
}
Run Code Online (Sandbox Code Playgroud)

小智 5

这可能不是您正在寻找的内容,但为什么不将结果存储在属性服务中呢?这种存储是永久性的。您可以检查结果是否已经在存储中,并可能将“缓存”的年龄存储在那里。

https://developers.google.com/apps-script/reference/properties/properties-service