Apps Developer Blog

Information for Google Apps Developers

Caching in the Cloud with Google Apps Script

November 2, 2011
Share on Google+ Share on Twitter Share on Facebook
Google
Labels: Apps Script

7 comments :

lcf said...

Where you were guys 6 months ago :)

It's been a long journey caching in ScriptProperties and such.

November 3, 2011 at 1:57 AM
Novack said...

Excellent!

November 3, 2011 at 7:21 AM
Sundew said...

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?

January 16, 2012 at 5:24 AM
Anton Soradoi said...

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

January 18, 2012 at 12:58 PM
Bruce Mcpherson said...

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

March 14, 2012 at 4:13 PM
Bruce Mcpherson said...

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

March 16, 2012 at 7:17 PM
commet said...

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

November 14, 2012 at 10:23 AM

Post a Comment

  

Labels


  • .NET 3
  • #io15 1
  • Admin SDK 4
  • Administrative APIs 26
  • AdSense 1
  • analytics 4
  • Android 5
  • App Engine 5
  • Apps Script 98
  • Auth 1
  • billing 4
  • Charts 1
  • Chrome OS 1
  • classroom 1
  • Cloud Storage API 1
  • Community 1
  • Developers 5
  • Directory API 1
  • Drive 2
  • Drive SDK 38
  • execution API 1
  • Firebase 1
  • Freemium 1
  • Fusion Tables 2
  • Gadgets 5
  • Gmail APIs 16
  • Google APIs 3
  • Google Apps 3
  • Google Apps Directory API 1
  • Google Apps Marketplace 3
  • Google Apps Script 1
  • Google Calendar API 20
  • Google Contacts API 3
  • Google Data Protocol 7
  • google docs 3
  • Google Docs API 20
  • Google Drive 2
  • Google Forms 4
  • Google I/O 3
  • Google Prediction API 3
  • Google Profiles API 2
  • Google sheets 2
  • Google Sites API 4
  • Google Spreadsheets API 4
  • Google Talk 1
  • Google Tasks API 6
  • Google+ 3
  • googlenew 1
  • Groups 2
  • Guest Post 42
  • ISVs 2
  • java 1
  • JavaScript 3
  • marketing 3
  • Marketplace 47
  • Marketplace ISV Guest 21
  • Migration 1
  • Mobile 1
  • mpstaffpick 1
  • oauth 11
  • OpenID 7
  • PHP 1
  • python 4
  • realtime API 1
  • Resellers 2
  • Ruby 1
  • SaaS 1
  • security 1
  • Staff Picks 2
  • webinar 2


Archive


  •     2015
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
  •     2014
    • Dec
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Mar
    • Feb
    • Jan
  •     2013
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
    • Jan
  •     2012
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
    • Jan
  •     2011
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
    • Jan
  •     2010
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb

Feed

Company-wide

  • Official Google Blog
  • Public Policy Blog
  • Student Blog

Products

  • Android Blog
  • Chrome Blog
  • Lat Long Blog

Developers

  • Developers Blog
  • Ads Developer Blog
  • Android Developers Blog
  • Google
  • Privacy
  • Terms