# Cache Service

Cache

This service allows a script to temporarily cache results that take time to
fetch/compute. 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.

## Classes

| Name | Brief description |
|---|---|
| `Cache` | A reference to a particular cache. |
| `CacheService` | CacheService allows you to access a cache for short term storage of data. |

## `Cache`

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `get(key)` | `String|null` | Gets the cached value for the given key, or `null` if none is found. |
| `getAll(keys)` | `Object` | Returns a JavaScript Object containing all key/value pairs found in the cache for an array of keys. |
| `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). |
| `putAll(values)` | `void` | Adds a set of key/value pairs to the cache. |
| `putAll(values, expirationInSeconds)` | `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. |
| `removeAll(keys)` | `void` | Removes a set of entries from the cache. |

## `CacheService`

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `getDocumentCache()` | `Cache|null` | Gets the cache instance scoped to the current document and script. |
| `getScriptCache()` | `Cache` | Gets the cache instance scoped to the script. |
| `getUserCache()` | `Cache` | Gets the cache instance scoped to the current user and script. |