Class CacheService

CacheService

CacheService allows you to access a cache for short term storage of data.
This class lets you get a specific cache instance. Public caches are for things that are not
dependent on which user is accessing your script. Private caches are for things which are
user-specific, like settings or recent activity.

Detailed documentation

getDocumentCache()

Gets the cache instance scoped to the current document and script. Document caches are specific
to the current document which contains the script. Use these to store script information that
is specific to the current document. If this method is called outside of the context of a
containing document (such as from a standalone script or web app), this method returns
null.

// Gets a cache that is specific to the current document containing the script
var cache = CacheService.getDocumentCache();

Return

Cache — a document cache instance, or null if there is no containing document

getScriptCache()

Gets the cache instance scoped to the script. Script caches are common to all users of the
script. Use these to store information that is not specific to the current user.

// Gets a cache that is common to all users of the script
var cache = CacheService.getScriptCache();