Cache Service Stay organized with collections Save and categorize content based on your preferences.
AI-generated Key Takeaways
The Cache service allows a script to temporarily store results that take time to fetch or compute.
Public caches are for data not dependent on a specific user, while private caches are for user-specific information.
The Cache class represents a particular cache instance, and the CacheService class provides access to different caches.
The Cache class provides methods for getting, putting, and removing data from the cache, including setting expiration times and handling multiple key/value pairs.
The CacheService class provides methods to retrieve specific cache instances scoped to the document, script, or current user.
This service allows a script to temporarily cache results that take time tofetch/compute. Public caches are for things that are not dependent on which useris accessing your script. Private caches are for things which are user-specific,like settings or recent activity.
Classes
| Name | Brief description |
|---|---|
Cache | A reference to a particular cache. |
Cache | Cache |
Cache
Methods
| Method | Return type | Brief description |
|---|---|---|
get(key) | String | Gets the cached value for the given key, ornull if none is found. |
get | Object | Returns a JavaScript Object containing all key/value pairs found in the cache for an array ofkeys. |
put(key, value) | void | Adds a key/value pair to the cache. |
put(key, value, expirationInSeconds) | void | Adds a key/value pair to the cache, with an expiration time (in seconds). |
put | void | Adds a set of key/value pairs to the cache. |
put | void | Adds a set of key/value pairs to the cache, with an expiration time (in seconds). |
remove(key) | void | Removes an entry from the cache using the given key. |
remove | void | Removes a set of entries from the cache. |
CacheService
Methods
| Method | Return type | Brief description |
|---|---|---|
get | Cache | Gets the cache instance scoped to the current document and script. |
get | Cache | Gets the cache instance scoped to the script. |
get | Cache | Gets the cache instance scoped to the current user and script. |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.