Index: openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl,v
diff -u -r1.1.2.44 -r1.1.2.45
--- openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl	28 Nov 2022 17:49:22 -0000	1.1.2.44
+++ openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl	29 Dec 2022 12:52:06 -0000	1.1.2.45
@@ -3827,11 +3827,21 @@
     # from the cache, which can cause large mutex lock times.
     #
     if {[regexp {[*\]\[]} $cache_key_pattern]} {
-        foreach key [ns_cache names $cache_pool $cache_key_pattern] {
-            ns_cache flush $cache_pool $key
+        if {[namespace which ns_cache_eval] ne ""} {
+            #
+            # NaviServer variant
+            #
+            ::acs::clusterwide ns_cache_flush -glob $cache_pool $key
+        } else {
+            #
+            # AOLserver variant
+            #
+            foreach key [ns_cache names $cache_pool $cache_key_pattern] {
+                ns_cache flush $cache_pool $key
+            }
         }
     } else {
-        ns_cache flush $cache_pool $cache_key_pattern
+        acs::clusterwide ns_cache flush $cache_pool $cache_key_pattern
     }
 }
 
Index: openacs-4/packages/acs-templating/tcl/query-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/query-procs.tcl,v
diff -u -r1.50.2.7 -r1.50.2.8
--- openacs-4/packages/acs-templating/tcl/query-procs.tcl	27 Nov 2022 17:45:28 -0000	1.50.2.7
+++ openacs-4/packages/acs-templating/tcl/query-procs.tcl	29 Dec 2022 12:52:06 -0000	1.50.2.8
@@ -411,7 +411,7 @@
                 if { $timeout > [ns_time] } {
                     set success 1
                 } else {
-                    ns_cache flush template_query_cache $cache_key
+                    acs::clusterwide ns_cache flush template_query_cache $cache_key
                 }
             }
         }
@@ -512,9 +512,9 @@
     foreach name $names {
         if { [string match $cache_match $name] } {
             ns_log debug "template::query::flush_cache: FLUSHING QUERY (persistent): $name"
-            ns_cache flush template_query_cache $name
+            acs::clusterwide ns_cache flush template_query_cache $name
             if {[ns_info name] ne "NaviServer"} {
-                ns_cache flush template_timeout_cache $name
+                acs::clusterwide ns_cache flush template_timeout_cache $name
             }
         }
     }
@@ -1032,8 +1032,8 @@
                     # validate timeout
                     if { $timeout > [ns_time] } {
                         set result $value
-                   } else {
-                        ns_cache flush template_cache $cache_key
+                    } else {
+                        acs::clusterwide ns_cache flush template_cache $cache_key
                     }
                 }
             }
@@ -1064,13 +1064,13 @@
         flush {
             # The key is actually a string match pattern
             if {[ns_info name] eq "NaviServer"} {
-                ns_cache_flush -glob template_cache $cache_key
+                acs::clusterwide ns_cache_flush -glob template_cache $cache_key
             } else {
                 set names [ns_cache names template_cache]
                 foreach name $names {
                     if { [string match $cache_key $name] } {
                         ns_log debug "template::cache: FLUSHING CACHE: $name"
-                        ns_cache flush template_cache $name
+                        acs::clusterwide ns_cache flush template_cache $name
                     }
                 }
             }
Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v
diff -u -r1.542.2.168 -r1.542.2.169
--- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl	24 Dec 2022 16:33:24 -0000	1.542.2.168
+++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl	29 Dec 2022 12:52:06 -0000	1.542.2.169
@@ -5390,7 +5390,7 @@
     if {$group_id eq ""} {
       # group::new does not flush the cache - sigh!  Therefore, we have
       # to flush the old cache entry here manually.
-      ns_cache flush util_memoize \
+      ::acs::clusterwide ns_cache flush util_memoize \
           "group::get_id_not_cached -group_name $group_name -subsite_id {} -application_group_id {}"
       set group_id [group::new -group_name $group_name]
     }