簡體   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