I'm testing it in one of my apps and wondering how long the cache guaranteed to be last for each (private/public) type.
I made a simple unit test, and first time the cache was valid for about three hours, and on the second time, it lasted about four hours. After then, key-value pairs were start disappearing not in noticeable order..
My next question is how to renew the cache before disappearing then. It seems calling any methods of existing cache instance didn't extended the life time. Should I create a new instance before the deadline and copy the contents over for maintaining a persistent one?
The purpose of cache is to *temporarily* store the data that you need a quick access to. This does mean that you will need to recreate the CacheInstance if you wish to keep it for loner than was intended.
Here is some Cache Service data: Default Expiration: 10 minutes. Maximum Expiration: 6 hours. Minumum Expiration: 1 second(silly, I know) Maximum Storage: 100KB
This is great, but i was rather looking for a way of 'locally caching' values in a Google Docs Sheet, so I could read them all at once, just once, and then access them in cache. Here is how that turned out if anyone else is looking. I havent tested the difference yet, but I will get round to it and publish that. I must admit I was kind of surprised that local caching of google docs data wasn't somehow already native and hidden in the API. Maybe it is?
As a follow up to the caching the getValue() method, I did some timings.
Im getting results of a 70 times improvement. See this blog post for details http://excelramblings.blogspot.com/2012/03/speeding-up-google-apps-script.html
Question for Bruce - Hi Bruce, I looked at your caching code. Looks interesting but not sure how to cache across separate function calls, That is with "sheetCache" I do not want to open a new spreadsheet every time and create a new worksheet range.
Once I initiate sheetCache, what arguments can I use to call it a second time without reopening the spreadsheet again?
7 comments :
Where you were guys 6 months ago :)
It's been a long journey caching in ScriptProperties and such.
Excellent!
I'm testing it in one of my apps and wondering how long the cache guaranteed to be last for each (private/public) type.
I made a simple unit test, and first time the cache was valid for about three hours, and on the second time, it lasted about four hours. After then, key-value pairs were start disappearing not in noticeable order..
My next question is how to renew the cache before disappearing then.
It seems calling any methods of existing cache instance didn't extended the life time. Should I create a new instance before the deadline and copy the contents over for maintaining a persistent one?
Sundew,
The purpose of cache is to *temporarily* store the data that you need a quick access to. This does mean that you will need to recreate the CacheInstance if you wish to keep it for loner than was intended.
Here is some Cache Service data:
Default Expiration: 10 minutes.
Maximum Expiration: 6 hours.
Minumum Expiration: 1 second(silly, I know)
Maximum Storage: 100KB
Best,
Anton
This is great, but i was rather looking for a way of 'locally caching' values in a Google Docs Sheet, so I could read them all at once, just once, and then access them in cache. Here is how that turned out if anyone else is looking. I havent tested the difference yet, but I will get round to it and publish that. I must admit I was kind of surprised that local caching of google docs data wasn't somehow already native and hidden in the API. Maybe it is?
http://ramblings.mcpher.com/Home/excelquirks/gooscript/optimize
Bruce
As a follow up to the caching the getValue() method, I did some timings.
Im getting results of a 70 times improvement. See this blog post for details
http://excelramblings.blogspot.com/2012/03/speeding-up-google-apps-script.html
bruce
Question for Bruce - Hi Bruce, I looked at your caching code. Looks interesting but not sure how to cache across separate function calls, That is with "sheetCache" I do not want to open a new spreadsheet every time and create a new worksheet range.
Once I initiate sheetCache, what arguments can I use to call it a second time without reopening the spreadsheet again?
Thanks JS
Post a Comment