Index: openacs-4/packages/acs-tcl/tcl/acs-cache-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/acs-cache-procs.tcl,v diff -u -r1.10.2.20 -r1.10.2.21 --- openacs-4/packages/acs-tcl/tcl/acs-cache-procs.tcl 12 Nov 2021 08:59:03 -0000 1.10.2.20 +++ openacs-4/packages/acs-tcl/tcl/acs-cache-procs.tcl 18 Nov 2021 19:56:14 -0000 1.10.2.21 @@ -686,8 +686,27 @@ } } +namespace eval ::acs { + ad_proc -private try_cache {cache key cmd} { + Function to support caching during bootstrap. When the + provided cache exists, then use it for caching, otherwise + perform uncalled call. This function is made intentionally + private, since this should only be required during + bootstraping. It does not make sense to wrap arbitrary caching + calls with this function. + } { + if {[info commands $cache] ne ""} { + return [uplevel [list $cache eval $key $cmd]] + } else { + ns_log warning "no cache $cache: need direct call $key $cmd" + return [uplevel $cmd] + } + } +} + + # Local variables: # mode: tcl # tcl-indent-level: 4 Index: openacs-4/packages/acs-tcl/tcl/apm-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.tcl,v diff -u -r1.114.2.35 -r1.114.2.36 --- openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 18 Nov 2021 19:13:47 -0000 1.114.2.35 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 18 Nov 2021 19:56:15 -0000 1.114.2.36 @@ -1022,19 +1022,13 @@ Returns 1 if there is an installed package version corresponding to the package_key, 0 otherwise. Uses a cached value for performance. } { - set sql { - select 1 from apm_package_versions - where package_key = :package_key - and installed_p = 't' + acs::try_cache ::acs::misc_cache apm_package_installed-$package_key { + db_0or1row apm_package_installed_p { + select 1 from apm_package_versions + where package_key = :package_key + and installed_p = 't' + } } - if {[info commands ::acs::misc_cache] ne ""} { - return [acs::misc_cache eval apm_package_installed-$package_key { - db_0or1row apm_package_installed_p $sql - }] - } else { - ns_log warning "apm_package_installed_p $package_key needs direct query" - return [db_0or1row apm_package_installed_p $sql] - } } ad_proc -public -debug apm_package_enabled_p { @@ -1043,19 +1037,13 @@ Returns 1 if there is an enabled package version corresponding to the package_key and 0 otherwise. } { - set sql { - select 1 from apm_package_versions - where package_key = :package_key - and enabled_p = 't' + acs::try_cache ::acs::misc_cache apm_package_enabled-$package_key { + db_0or1row apm_package_enabled_p { + select 1 from apm_package_versions + where package_key = :package_key + and enabled_p = 't' + } } - if {[info commands ::acs::misc_cache] ne ""} { - return [acs::misc_cache eval apm_package_enabled-$package_key { - db_0or1row apm_package_enabled_p $sql - }] - } else { - ns_log warning "apm_package_enabled_p $package_key needs direct query" - return [db_0or1row apm_package_enabled_p $sql] - } } ad_proc -public apm_enabled_packages {} {