CacheService.getUserCache().put('example','hello',600)
That cache will expire in 600 seconds, or 10 minutes.
But what about this situation?
//Current time is 18:30
CacheService.getUserCache().put('example','hello',600)
//Cache is gonna expire in 18:40
Utilities.sleep(60000)
//1 minute of sleep later ( about 18:31 )
CacheService.getUserCache().put('example','hello')
Will this cache expire in 18:40 as expected or will it expire 1 minute later since it got updated 1 minute after?
(Basically does the expiration date resets every time you update cache by using .put()?)
function testCache() {
var scriptCache;
scriptCache = CacheService.getScriptCache();
scriptCache.put('example','hello',600);
Logger.log(scriptCache.get('example'));
scriptCache.put('example','goodbye',1);//save a different value to the same key but with only 1 second
Utilities.sleep(1100);////1.1 second of sleep later
Logger.log(scriptCache.get('example'));
}
[19-05-05 15:58:20:369 EDT] hello
[19-05-05 15:58:21:559 EDT] null