memoize-procs-naviserver.tcl

Defines a convenient cache mechanism, util_memoize.

Location:
packages/acs-tcl/tcl/memoize-procs-naviserver.tcl
Created:
2000-10-19
Authors:
Various [acs@arsdigita.com]
Rob Mayoff
Victor Guerra
Gustaf Neumann
CVS Identification:
$Id: memoize-procs-naviserver.tcl,v 1.9.2.7 2022/12/29 12:54:06 gustafn Exp $

Procedures in this file

Detailed information

util_memoize (public)

 util_memoize script [ max_age ]

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 - 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):
%3 test_util_memoize_cache util_memoize_cache (test acs-tcl) util_memoize util_memoize test_util_memoize_cache->util_memoize test_util_memoize_cache_flush util_memoize_cache_flush (test acs-tcl) test_util_memoize_cache_flush->util_memoize test_util_memoize_cache_script util_memoize_cache_script (test acs-tcl) test_util_memoize_cache_script->util_memoize Class ::xowiki::includelet::random-form-page Class ::xowiki::includelet::random-form-page (public) Class ::xowiki::includelet::random-form-page->util_memoize acs::root_of_host_noncached acs::root_of_host_noncached (private) acs::root_of_host_noncached->util_memoize acs_lookup_magic_object acs_lookup_magic_object (private, deprecated) acs_lookup_magic_object->util_memoize acs_object::package_id acs_object::package_id (public) acs_object::package_id->util_memoize acs_object_type::get_table_name acs_object_type::get_table_name (public) acs_object_type::get_table_name->util_memoize

Testcases:
util_memoize_cache, util_memoize_cache_script, util_memoize_cache_flush

util_memoize_cached_p (public)

 util_memoize_cached_p script [ max_age ]

Check whether script's value has been cached, and whether it was cached no more than max_age seconds ago.

Parameters:
script - A Tcl script.
max_age (optional) - Maximum age of cached value in seconds.
Returns:
Boolean value.

Partial Call Graph (max 5 caller/called nodes):
%3 test_util_memoize_cache util_memoize_cache (test acs-tcl) util_memoize_cached_p util_memoize_cached_p test_util_memoize_cache->util_memoize_cached_p test_util_memoize_cache_flush util_memoize_cache_flush (test acs-tcl) test_util_memoize_cache_flush->util_memoize_cached_p test_util_memoize_cache_script util_memoize_cache_script (test acs-tcl) test_util_memoize_cache_script->util_memoize_cached_p ad_get_client_property ad_get_client_property (public) ad_get_client_property->util_memoize_cached_p package_object_view_reset package_object_view_reset (public) package_object_view_reset->util_memoize_cached_p package_recreate_hierarchy package_recreate_hierarchy (public) package_recreate_hierarchy->util_memoize_cached_p

Testcases:
util_memoize_cache, util_memoize_cache_script, util_memoize_cache_flush

util_memoize_flush_pattern (public)

 util_memoize_flush_pattern [ -log ] pattern

Loop through all cached entries, flushing all that match the pattern that was passed in.

Switches:
-log
(boolean) (optional)
Whether to log keys checked and flushed (useful for debugging).
Parameters:
pattern - Match pattern (glob pattern like in 'string match $pattern ...').

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_subsite_check_composite_group acs_subsite_check_composite_group (test acs-subsite) util_memoize_flush_pattern util_memoize_flush_pattern test_acs_subsite_check_composite_group->util_memoize_flush_pattern test_acs_subsite_expose_bug_775 acs_subsite_expose_bug_775 (test acs-subsite) test_acs_subsite_expose_bug_775->util_memoize_flush_pattern test_group_localization group_localization (test acs-subsite) test_group_localization->util_memoize_flush_pattern acs::clusterwide acs::clusterwide util_memoize_flush_pattern->acs::clusterwide ad_log ad_log (public) util_memoize_flush_pattern->ad_log group::new group::new (public) group::new->util_memoize_flush_pattern workflow::case::flush_cache workflow::case::flush_cache (private) workflow::case::flush_cache->util_memoize_flush_pattern workflow::case::role::flush_cache workflow::case::role::flush_cache (private) workflow::case::role::flush_cache->util_memoize_flush_pattern

Testcases:
group_localization, acs_subsite_expose_bug_775, acs_subsite_check_composite_group

util_memoize_seed (public)

 util_memoize_seed script value [ max_age ]

Pretend util_memoize was called with script and it returned value. Cache value, replacing any previous cache entry for script.

If clustering is enabled, this command flushes script's value from the caches on all servers in the cluster before storing the new value. The new value is only stored in the local cache.

Parameters:
script - A Tcl script that presumably would return value.
value - The value to cache for script.
max_age (optional) - Not used.

Partial Call Graph (max 5 caller/called nodes):
%3 ad_set_client_property ad_set_client_property (public) util_memoize_seed util_memoize_seed ad_set_client_property->util_memoize_seed apidoc::tclcode_to_html apidoc::tclcode_to_html (public) apidoc::tclcode_to_html->util_memoize_seed auth::sync::job::get_authority_id_seed auth::sync::job::get_authority_id_seed (private) auth::sync::job::get_authority_id_seed->util_memoize_seed bug_tracker::bugs_exist_p_set_true bug_tracker::bugs_exist_p_set_true (public) bug_tracker::bugs_exist_p_set_true->util_memoize_seed workflow::action::get_all_info_not_cached workflow::action::get_all_info_not_cached (private) workflow::action::get_all_info_not_cached->util_memoize_seed

Testcases:
No testcase defined.
[ show source ]