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.37 -r1.10.2.38 --- openacs-4/packages/acs-tcl/tcl/acs-cache-procs.tcl 26 Nov 2022 16:53:57 -0000 1.10.2.37 +++ openacs-4/packages/acs-tcl/tcl/acs-cache-procs.tcl 29 Dec 2022 12:54:06 -0000 1.10.2.38 @@ -143,7 +143,7 @@ # avoided. The partitioned variants can help to reduce # the lock times. # - return [ns_cache_flush -glob [:cache_name $partition_key] $pattern] + return [::acs::clusterwide ns_cache_flush -glob [:cache_name $partition_key] $pattern] } :method cache_create {name size} { @@ -217,7 +217,7 @@ # Flush all entries in a cache. Both, NaviServer and # AOLserver support "ns_cache_flush". # - ns_cache_flush [:cache_name $partition_key] + ::acs::clusterwide ns_cache_flush [:cache_name $partition_key] #ns_log notice "flush_all -> ns_cache_flush [:cache_name $partition_key]" #ns_log notice "... content of ${:name}: [ns_cache_keys ${:name}]" } @@ -297,7 +297,7 @@ # NaviServer and AOLserver support "ns_cache_flush". # for {set i 0} {$i < ${:partitions}} {incr i} { - ns_cache_flush ${:name}-$i + ::acs::clusterwide ns_cache_flush ${:name}-$i #ns_log notice "flush_all: ns_cache_flush ${:name}-$i" #ns_log notice "... content of ${:name}-$i: [ns_cache_keys ${:name}-$i]" } @@ -313,7 +313,7 @@ # a pattern. # for {set i 0} {$i < ${:partitions}} {incr i} { - ns_cache_flush -glob ${:name}-$i $pattern + ::acs::clusterwide ns_cache_flush -glob ${:name}-$i $pattern ns_log notice "flush_pattern_in_all_partitions: ns_cache_flush ${:name}-$i $pattern" #ns_log notice "... content of ${:name}-$i: [ns_cache_keys ${:name}-$i]" } @@ -503,13 +503,31 @@ return $value } + #:public method flush { + # {-pattern *} + #} { + # # + # # Flush a cache entry based on the pattern (which might be + # # wild-card-free). + # # + # ::acs::clusterwide [self] flush_local -pattern $pattern + #} + :public method flush { {-pattern *} } { # # Flush a cache entry based on the pattern (which might be - # wild-card-free). + # wild-card-free). Currently, the clusterwide flushing is + # omitted. # + # We have the per-request cache (clusterwide operations do + # not make sense for this) and per-thread caching. The + # per-thread caching application have to be aware that + # flushing is happening only in one thread, so clusterwide + # operations will only start to make sense, when the all + # threads of a server would be cleaned. + # if {[info exists ${:prefix}]} { if {$pattern eq "*"} { ns_log notice "### dict flush ${:prefix} <$pattern>" @@ -524,6 +542,9 @@ dict unset ${:prefix} $key } } elseif [dict exists [set ${:prefix}] $pattern] { + # + # A "pattern" without a wildcard was provided + # dict unset ${:prefix} $pattern } } Index: openacs-4/packages/acs-tcl/tcl/memoize-procs-naviserver.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/memoize-procs-naviserver.tcl,v diff -u -r1.9.2.6 -r1.9.2.7 --- openacs-4/packages/acs-tcl/tcl/memoize-procs-naviserver.tcl 5 Jan 2021 17:10:17 -0000 1.9.2.6 +++ openacs-4/packages/acs-tcl/tcl/memoize-procs-naviserver.tcl 29 Dec 2022 12:54:06 -0000 1.9.2.7 @@ -118,14 +118,14 @@ pattern } { - Loop through all cached scripts, flushing all that match the + Loop through all cached entries, flushing all that match the pattern that was passed in. @param pattern Match pattern (glob pattern like in 'string match $pattern ...'). @param log Whether to log keys checked and flushed (useful for debugging). } { - set nr_flushed [ns_cache_flush -glob util_memoize $pattern] + set nr_flushed [::acs::clusterwide ns_cache_flush -glob util_memoize $pattern] if {$log_p} { ad_log notice "util_memoize_flush_pattern: flushed $nr_flushed entries using the pattern: $pattern" } Index: openacs-4/packages/acs-tcl/tcl/memoize-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/memoize-procs.tcl,v diff -u -r1.18.2.4 -r1.18.2.5 --- openacs-4/packages/acs-tcl/tcl/memoize-procs.tcl 13 Jul 2022 09:54:32 -0000 1.18.2.4 +++ openacs-4/packages/acs-tcl/tcl/memoize-procs.tcl 29 Dec 2022 12:54:06 -0000 1.18.2.5 @@ -55,10 +55,11 @@ } -ad_proc -private util_memoize_flush_local {script} { - Forget any cached value for script. You probably want to use - util_memoize_flush to flush the caches on all servers - in the cluster, in case clustering is enabled. +ad_proc -private util_memoize_flush_local {script} { + Forget any cached value for script on the local server. + You probably want to use util_memoize_flush to flush + the caches on all servers in the cluster, in case clustering is + enabled. @param script The Tcl script whose cached value should be flushed. } { @@ -74,7 +75,7 @@ ::acs::clusterwide ns_cache flush util_memoize $script } -ad_proc -public util_memoize_flush_regexp { +ad_proc -private util_memoize_flush_regexp_local { -log:boolean expr } { @@ -104,6 +105,29 @@ } } +ad_proc -public util_memoize_flush_regexp { + -log:boolean + expr +} { + Loop through all cached entries, flushing all that match the + regular expression that was passed in. + + It is recommended to use util_memoize_flush_pattern whenever + possible, since glob-match is in most cases sufficient and much + better performance-wise. the glob match can be better supported by + the built-in set of the server. + + @see util_memoize_flush_pattern + + @param expr The regular expression to match. + @param log Whether to log keys checked and flushed (useful for debugging). +} { + ::acs::clusterwide util_memoize_flush_regexp_local \ + {*}[expr {$log_p ? "-log" : ""}] \ + $expr +} + + # Local variables: # mode: tcl # tcl-indent-level: 4