generated at
Apps Script Cache Service
制約
500KB, 0.5M
大き目のものは、spreadsheet, firestore, bigqueryなどに退避するのが妥当そう。
keyは、250 chars
key:valueとしては、100KB
アイテム数は1000個まで
また、予告なしに、システム側の都合で削除される可能性もある。
cacheされる時間は、defaultが10分だが、、最大は,,,

アイテム数が1000個までいけるが、900個を超えたら....みたいな表現があるので、500個くらいに分割して保存、取り出しをする. 5MBまで行ける
GAS_CacheDistribute.js
/** * 分割した文字列をキャッシュに保存します。 * * @param {string} cacheName - キャッシュ名。各分割文字列のキャッシュのキーにも使用されます。 * @param {string} value - キャッシュに保存する文字列。この文字列は100KBの部分文字列に分割されます。 * @throws {Error} valueの長さが100KB * 500を超える場合に投げられます。 */ function putCache(cacheName, value) { if (typeof value != 'string' || value.length > 100 * 1024 * 500) { throw new Error("キャッシュに入れようとする値の容量が 5MBを超えています or 文字列でない"); } var cache = CacheService.getScriptCache(); var parts = []; for (var i = 0; i < value.length; i += 100 * 1024) { parts.push(value.substring(i, i + 100 * 1024)); } for (var i = 0; i < parts.length; i++) { cache.put(cacheName + "_" + i, parts[i]); } cache.put(cacheName + "_parts", parts.length.toString()); } /** * キャッシュから文字列を取得します。 * * @param {string} cacheName - キャッシュ名。分割文字列のキャッシュのキーにも使用されます。 * @returns {string|null} キャッシュから取得した文字列。キャッシュが存在しない場合はnull。 */ function getCache(cacheName) { const cache = CacheService.getScriptCache(); const cache_parts = cache.get(cacheName + "_parts") if(!cache_parts) return null const parts = parseInt(cache_parts); let value = ""; for (var i = 0; i < parts; i++) { value += cache.get(cacheName + "_" + i); } return value; }

RSSの例。ドキュメントにある参考例
rssCache.js
function getRssFeed() { var cache = CacheService.getScriptCache(); var cached = cache.get("rss-feed-contents"); if (cached != null) { return cached; } var result = UrlFetchApp.fetch("http://example.com/my-slow-rss-feed.xml"); // takes 20 seconds var contents = result.getContentText(); cache.put("rss-feed-contents", contents, 1500); // cache for 25 minutes return contents; }
>expirationInSeconds Integer the maximum time the value remains in the cache, in seconds. The minimum is 1 second and the maximum is 21600 seconds (6 hours).