util_memoize (public)
util_memoize script [ max_age ]
Defined in packages/acs-tcl/tcl/memoize-procs-naviserver.tcl
If script has been executed before, return the value it returned last time, unless it was more than max_age seconds ago.
Otherwise, evaluate script and cache and return the result.
Note: script is not evaluated with
uplevel
.
- Parameters:
- script (required)
- A Tcl script whose value should be memoized. May be best to pass this as a list, e.g.
[list someproc $arg1 $arg2]
.- max_age (optional)
- The maximum age in seconds for the cached value of script. If the cached value is older than max_age seconds, script will be re-executed.
- Returns:
- The possibly-cached value returned by script.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- util_memoize_cache, util_memoize_cache_script, util_memoize_cache_flush