Index: openacs-4/packages/acs-tcl/acs-tcl.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/acs-tcl.info,v diff -u -N -r1.95.2.33 -r1.95.2.34 --- openacs-4/packages/acs-tcl/acs-tcl.info 1 Oct 2021 07:30:07 -0000 1.95.2.33 +++ openacs-4/packages/acs-tcl/acs-tcl.info 4 Oct 2021 09:37:00 -0000 1.95.2.34 @@ -9,7 +9,7 @@ f t - + OpenACS The Kernel Tcl API library. 2021-09-15 @@ -18,7 +18,7 @@ GPL version 2 3 - + 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 -N -r1.10.2.15 -r1.10.2.16 --- openacs-4/packages/acs-tcl/tcl/acs-cache-procs.tcl 24 Sep 2021 11:31:03 -0000 1.10.2.15 +++ openacs-4/packages/acs-tcl/tcl/acs-cache-procs.tcl 4 Oct 2021 09:37:01 -0000 1.10.2.16 @@ -444,7 +444,7 @@ #ns_log notice "### cmd returns <$value> no_empty $no_empty " if {$no_empty && $value eq ""} { return "" - } + } dict set ${:prefix} $key $value #ns_log notice "### [list dict set ${:prefix} $key $value]" } @@ -459,16 +459,16 @@ # Flush a cache entry based on the pattern (which might be # wild-card-free). # - if {[info exists ${:prefix}]} { + if {[info exists ${:prefix}]} { if {$pattern eq "*"} { - ns_log notice "### dict flush ${:prefix} <$pattern>" + ns_log notice "### dict flush ${:prefix} <$pattern>" unset ${:prefix} } elseif {[string first "*" $pattern] != -1} { # # A real pattern with wild-card was provided. - # + # set keys [dict keys [set ${:prefix}] $pattern] - ns_log notice "### dict flush ${:prefix} <$pattern> -> [llength $keys]]" + ns_log notice "### dict flush ${:prefix} <$pattern> -> [llength $keys]]" foreach key $keys { dict unset ${:prefix} $key } @@ -477,7 +477,7 @@ } } } - + # # The per-request cache uses Tcl variables in the global # namespace, such they are automatically reclaimed after the @@ -488,7 +488,7 @@ # # Define the "per_thread_cache" # - if {[ns_config "ns/parameters" cachingmode singlenode] eq "none"} { + if {[ns_config "ns/parameters" cachingmode "per-node"] eq "none"} { # # If caching mode is "none", let the "per_thread_cache" behave # like the "per_request_cache". @@ -559,7 +559,9 @@ nsv_set "" nsv_unset "" nsv_incr "" + nsv_dict "" bgdelivery "" + callback "" ns_cache "^ns_cache\s+eval" ns_cache_flush "" acs::cache_flush_all "" Index: openacs-4/packages/acs-tcl/tcl/defs-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/defs-procs.tcl,v diff -u -N -r1.81.2.10 -r1.81.2.11 --- openacs-4/packages/acs-tcl/tcl/defs-procs.tcl 6 Aug 2021 04:40:27 -0000 1.81.2.10 +++ openacs-4/packages/acs-tcl/tcl/defs-procs.tcl 4 Oct 2021 09:37:01 -0000 1.81.2.11 @@ -437,56 +437,174 @@ return [ns_config "ns/server/[ns_info server]/acs/$package_key" $name] } +# +# Implementation of ad_parameter_cache +# 1) for cachingmode none +# 2) via "nsv_dict" (cluster aware) +# 3) via "nsv" (not cluster aware) -ad_proc -public ad_parameter_cache { - -set - -delete:boolean - -global:boolean - key - parameter_name -} { +if {[ns_config "ns/parameters" cachingmode "per-node"] eq "none"} { + # + # If caching mode is "none", the "ad_parameter_cache" is + # essentially a no-op stub, but it is used for interface + # compatibility. + # + # TODO: One should essentially define more more cachetype for + # nsv_caching in acs-cache-procs to reduce redundancy and for + # providing higher orthogonality. + # + ad_proc -public ad_parameter_cache { + -set + -delete:boolean + -global:boolean + key + parameter_name + } { - Manages the cache for ad_parameter. - @param set Use this flag to indicate a value to set in the cache. - @param delete Delete the value from the cache - @param global If true, global param, false, instance param - @param key Specifies the key for the cache'd parameter, either the package instance - id (instance parameter) or package key (global parameter). - @param parameter_name Specifies the parameter name that is being cached. - @return The cached value. + Stub for a parameter cache, since "cachingmode" is "none". -} { - if {$delete_p} { - if {[nsv_exists ad_param_$key $parameter_name]} { - nsv_unset ad_param_$key $parameter_name + @param set Use this flag to indicate a value to set in the cache. + @param delete Delete the value from the cache + @param global If true, global param, false, instance param + @param key Specifies the key for the cache'd parameter, either the package instance + id (instance parameter) or package key (global parameter). + @param parameter_name Specifies the parameter name that is being cached. + @return The cached value. + + } { + if {$delete_p} { + return } - return + if {[info exists set]} { + return $set + } elseif { $global_p } { + set value [db_string select_global_parameter_value { + select apm_parameter_values.attr_value + from apm_parameters, apm_parameter_values + where apm_parameter_values.package_id is null + and apm_parameter_values.parameter_id = apm_parameters.parameter_id + and apm_parameters.parameter_name = :parameter_name + and apm_parameters.package_key = :key + } -default ""] + } else { + set value [db_string select_instance_parameter_value { + select apm_parameter_values.attr_value + from apm_parameters, apm_parameter_values + where apm_parameter_values.package_id = :key + and apm_parameter_values.parameter_id = apm_parameters.parameter_id + and apm_parameters.parameter_name = :parameter_name + } -default ""] + } + return $value } - if {[info exists set]} { - nsv_set "ad_param_${key}" $parameter_name $set - return $set - } elseif { [nsv_exists ad_param_$key $parameter_name] } { - return [nsv_get ad_param_$key $parameter_name] - } elseif { $global_p } { - set value [db_string select_global_parameter_value { - select apm_parameter_values.attr_value - from apm_parameters, apm_parameter_values - where apm_parameter_values.package_id is null - and apm_parameter_values.parameter_id = apm_parameters.parameter_id - and apm_parameters.parameter_name = :parameter_name - and apm_parameters.package_key = :key - } -default ""] - } else { - set value [db_string select_instance_parameter_value { - select apm_parameter_values.attr_value - from apm_parameters, apm_parameter_values - where apm_parameter_values.package_id = :key - and apm_parameter_values.parameter_id = apm_parameters.parameter_id - and apm_parameters.parameter_name = :parameter_name - } -default ""] + +} elseif {[::acs::icanuse "nsv_dict"]} { + + if {![nsv_array exists ad_param]} { + nsv_set ad_param . . } - nsv_set "ad_param_${key}" $parameter_name $value - return $value + + ad_proc -public ad_parameter_cache { + -set + -delete:boolean + -global:boolean + key + parameter_name + } { + + Manages the cache for ad_parameter. + @param set Use this flag to indicate a value to set in the cache. + @param delete Delete the value from the cache + @param global If true, global param, false, instance param + @param key Specifies the key for the cache'd parameter, either the package instance + id (instance parameter) or package key (global parameter). + @param parameter_name Specifies the parameter name that is being cached. + @return The cached value. + + } { + if {$delete_p} { + if {[nsv_dict exists ad_param $key $parameter_name]} { + ::acs::clusterwide nsv_dict unset ad_param $key $parameter_name + } + return + } + if {[info exists set]} { + nsv_dict set ad_param $key $parameter_name $set + return $set + } elseif { [nsv_dict get -varname value ad_param $key $parameter_name] } { + return $value + } elseif { $global_p } { + set value [db_string select_global_parameter_value { + select apm_parameter_values.attr_value + from apm_parameters, apm_parameter_values + where apm_parameter_values.package_id is null + and apm_parameter_values.parameter_id = apm_parameters.parameter_id + and apm_parameters.parameter_name = :parameter_name + and apm_parameters.package_key = :key + } -default ""] + } else { + set value [db_string select_instance_parameter_value { + select apm_parameter_values.attr_value + from apm_parameters, apm_parameter_values + where apm_parameter_values.package_id = :key + and apm_parameter_values.parameter_id = apm_parameters.parameter_id + and apm_parameters.parameter_name = :parameter_name + } -default ""] + } + nsv_dict set ad_param $key $parameter_name $value + return $value + } +} else { + ad_proc -public ad_parameter_cache { + -set + -delete:boolean + -global:boolean + key + parameter_name + } { + + Manages the cache for ad_parameter. + @param set Use this flag to indicate a value to set in the cache. + @param delete Delete the value from the cache + @param global If true, global param, false, instance param + @param key Specifies the key for the cache'd parameter, either the package instance + id (instance parameter) or package key (global parameter). + @param parameter_name Specifies the parameter name that is being cached. + @return The cached value. + + } { + if {$delete_p} { + if {[nsv_exists ad_param_$key $parameter_name]} { + nsv_unset ad_param_$key $parameter_name + } + return + } + if {[info exists set]} { + nsv_set "ad_param_${key}" $parameter_name $set + return $set + } elseif { [nsv_exists ad_param_$key $parameter_name] } { + return [nsv_get ad_param_$key $parameter_name] + } elseif { $global_p } { + set value [db_string select_global_parameter_value { + select apm_parameter_values.attr_value + from apm_parameters, apm_parameter_values + where apm_parameter_values.package_id is null + and apm_parameter_values.parameter_id = apm_parameters.parameter_id + and apm_parameters.parameter_name = :parameter_name + and apm_parameters.package_key = :key + } -default ""] + } else { + set value [db_string select_instance_parameter_value { + select apm_parameter_values.attr_value + from apm_parameters, apm_parameter_values + where apm_parameter_values.package_id = :key + and apm_parameter_values.parameter_id = apm_parameters.parameter_id + and apm_parameters.parameter_name = :parameter_name + } -default ""] + } + nsv_set "ad_param_${key}" $parameter_name $value + return $value + } } ad_proc -private ad_parameter_cache_all {} { Index: openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl,v diff -u -N -r1.26.2.4 -r1.26.2.5 --- openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl 2 Sep 2021 17:10:27 -0000 1.26.2.4 +++ openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl 4 Oct 2021 09:37:01 -0000 1.26.2.5 @@ -43,7 +43,7 @@ db_exec_plsql set_parameter_value {} - callback subsite::global_parameter_changed \ + acs::clusterwide callback subsite::global_parameter_changed \ -package_key $package_key \ -parameter $parameter \ -value $value @@ -121,7 +121,7 @@ db_exec_plsql set_parameter_value {} - callback subsite::parameter_changed \ + acs::clusterwide callback subsite::parameter_changed \ -package_id $package_id \ -parameter $parameter \ -value $value