繁体   English   中英

Google Apps脚本-永久缓存

[英]Google Apps Script - Permanent Caching

我的工作表中有很多自定义函数调用。 我想永久缓存结果。 到目前为止,我一直使用缓存服务,但仅限于六个小时。 有没有一种方法可以永久地缓存结果? 我在这里读到评论,它有可能在用户的浏览器中缓存数据。 我应该如何实现呢?

谢谢 !

编辑:感谢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);
}

这可能不是您要找的东西,但是为什么不将结果存储在Properties Service中呢? 此存储是永久的。 您可以检查结果是否已经存储在其中,并可能在其中存储“缓存”的使用期限。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM