util_memoize
one of
the defined (but not documented) Tcl procedures in this
installation of the ACS
Usage:
util_memoize script { max_age "0" }
Source code:
if {$max_age < 0} {
set max_age 0
}
set current_time [ns_time]
set cached_p [ns_cache get util_memoize $script pair]
if {$cached_p && $max_age} {
set cache_time [lindex $pair 0]
if {$current_time - $cache_time > $max_age} {
ns_cache flush util_memoize $script
set cached_p 0
}
}
if {!$cached_p} {
set pair [ns_cache eval util_memoize $script {
list $current_time [eval $script]
}]
}
return [lindex $pair 1]