A generic Apps Script memoization function can be written to cache any function.
We’ve featured a couple of Apps Script optimisation techniques in the past. This example from Justin Poehnelt uses a technique found in many coding syntaxes of ‘memoization‘:
In computing, memoization or memoisation is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls to pure functions and returning the cached result when the same inputs occur again
In the example provided in the source post by Justin it defaults to
CacheService.getScriptCache() to store the memoized results but it would be easy to change this to
CacheService.getDocumentCache(). With a little modification you could also include Properties Service.