Returns a cache shared by all users of the script.
class CacheService method .getScriptCache()
CacheService is the Apps Script service.
.getScriptCache() is the method name you will see after a dot in your code.
What it does
Why it's used
- Share cached API results across all users of the add-on.
- Cut duplicate calls to slow external services.
Common errors
- Forgetting parentheses on getScriptCache. Write CacheService.getScriptCache(), not CacheService.getScriptCache or getScriptCache by itself.
- Skipping dots between chained calls. Each step needs a dot, like CacheService.getScriptCache().
- Adding spaces where they do not belong. Write CacheService.getScriptCache(), not CacheService .getScriptCache(), CacheService.getScriptCache (), or CacheService . getScriptCache().
- Wrong capitalization. Use CacheService and getScriptCache, not cacheservice or getscriptcache.
Explore
Related methods
-
.getUserCache()
Returns a cache private to the current user.
-
.getDocumentCache()
Returns a cache tied to the current spreadsheet or doc.
-
.get()
Reads a cached value by key.
-
.remove()
Deletes a cached value by key.
-
.put()
Stores a value in the cache for a set time.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.