-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support options.keyArgs to complement options.makeCacheKey.
This optional function takes the raw arguments passed to an OptimisticFunctionWrapper and simplifies/filters/reduces them down to an array of arguments sufficient to identify the cache result. This simplified array of arguments is then passed to options.makeCacheKey (or defaultMakeCacheKey if no options.makeCacheKey was provided). The returned array serves as the arguments list for any function that only needs to compute a cache key (and thus does not need the full raw arguments), such as wrapper.dirty and options.makeCacheKey. This makes it possible to dirty a cached function using less information than would be required to call it properly, which is useful in some cases. In some sense, options.keyArgs and options.makeCacheKey divide up the work of computing cache keys from raw arguments. Both functions are optional, and any combination of the two that satisfies the type system is allowed. If the sequence of arguments returned by options.keyArgs can be passed directly to defaultMakeCacheKey, you may not need to define a custom options.makeCacheKey function anymore.
- Loading branch information
Showing
2 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters