简体   繁体   中英

Google Apps Script - Permanent Caching

I have a sheet with a lot of custom functions calls. I would like to cache results permanently. Until now, I've used cache service, but it is limited to six hours. Is there a way to cache results permanently ? I read in the comments here , that it could be possible to cache data in the user's browser. How should I achieve this ?

Thanks !

Edit : Thanks to Serge Hendrickx's suggestion, I was able to cache results permanently using the same approach as cache service :

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);
}

This might not be exactly what you're looking for but why not store the results in the Properties Service? This storage is permanent. You could check if the result is already in storage, and potentially store the age of the 'cache' in there as well.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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