Stay organized with collections Save and categorize content based on your preferences.
CacheServiceCacheService 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.
The data you write to the cache is not guaranteed to persist until its expiration time. You must be prepared to get back null
from all reads.
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 const 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 const cache = CacheService.getScriptCache();Return
Cache
— a script cache instance
getUserCache()
Gets the cache instance scoped to the current user and script. User caches are specific to the current user of the script. Use these to store script information that is specific to the current user.
// Gets a cache that is specific to the current user of the script const cache = CacheService.getUserCache();Return
Cache
— a user cache instance
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["`CacheService` provides short-term storage for script data, offering document, script, and user-specific scopes."],["Data stored using `CacheService` is not guaranteed to persist and may return `null` when retrieved."],["Three cache instances are available: `getDocumentCache()` for document-specific data, `getScriptCache()` for script-wide data, and `getUserCache()` for user-specific data."],["When using `getDocumentCache()`, it returns `null` if called outside a document context (standalone script or web app)."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4