5
votes

What is GAS's quota for cache service? It's missing from documentation.

https://developers.google.com/apps-script/guides/services/quotas

1

1 Answers

7
votes

The following list details the aspects of Cache service that have limits.

  • key length - 250 Characters
  • value size - 100kb
  • expiration time - default is 600 seconds
  • Number of times accessed in one day - no documented limit
  • Number of times accessed in a very short period of time - no documented limit
  • Number of total keys that can be used - Don't know of a documented limit

Quote:

The maximum length of a key is 250 characters. The maximum amount of data that can be stored per key is 100KB. The value will expire from the cache after 600 seconds (10 minutes).

If you do not designate an expiration in seconds,then the default is 600 seconds.

put(key, value, expirationInSeconds)

There is a difference between quotas and limitations. Limitations are key length and value size. Quotas are how many times a day the service can be accessed.

put method - Apps Script Cache Service - reference

Service Quotas

Note that the value limit for one property in Properties Service is only 9kb, compared to 100 kb for Cache Service. Properties Service is similar, but not the same as Cache Service, and the value limits are different.

Other information:

  • Daily quotas are refreshed at the end of a 24-hour window

A common error with all Apps Script services is that the service was invoked too many times.

For example:

Too many simultaneous invocations

There is a difference between too many times in a short period of time, or too many times in a 24 hour period. If, for example, you had lots of users all running your script at the same time, then your code would be calling services many times in a short period of time. If the code needs to run from your account, as opposed to the code running from the account of the user, then you might need to use something other than Apps Script.

If your code is structured so that it's making too many service calls, then you could optimize your code.

If the error is from to many service calls in a short period of time, then you can catch the error, have the code wait, and then retry.