Index: openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl,v diff -u -N -r1.125 -r1.126 --- openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl 21 Jun 2018 07:23:56 -0000 1.125 +++ openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl 21 Jun 2018 09:19:51 -0000 1.126 @@ -721,7 +721,48 @@ ::xo::db::select_driver + nx::Class create ::xo::Cache { + # + # Provide a simple class to generalize cache management to extend + # cache primitiva (in the future, e.g. for cache partitioning). + # + :property parameter:required + :property package_key:required + :property maxentry:integer + :property {default_size:integer 10000} + + :public method flush {key} { + ::xo::clusterwide ns_cache flush ${:name} $key + } + + :public method init {} { + set :name [namespace tail [current]] + + if {[info commands ns_cache_create] ne ""} { + # + # Version for NaviServer, which allows us to provide maximum + # size for a single cache entry. + # + ns_cache_create \ + {*}[expr {[info exists :maxentry] ? "-maxentry ${:maxentry}" : ""}] \ + ${:name} \ + [parameter::get_from_package_key \ + -package_key ${:package_key} \ + -parameter ${:parameter} \ + -default ${:default_size}] + } else { + ns_cache create \ + ${:name} \ + -size [parameter::get_from_package_key \ + -package_key ${:package_key} \ + -parameter ${:parameter} \ + -default ${:default_size}] + } + } + } + + ########################################################################## # # The ns_caches below should exist, before any cached objects are @@ -735,58 +776,42 @@ # already. This change makes the object-cache-init.tcl # obsolete. # - # Unfortunately, ns_cache has no command to check, whether + # Unfortunately, AOLserver's ns_cache has no command to check, whether # a cache exists, so we use the little catch below to check. # try { ns_cache flush xotcl_object_cache NOTHING } on error {errorMsg} { ns_log notice "xotcl-core: creating xotcl-object caches" - if {[info commands ns_cache_create] ne ""} { - # - # Version for NaviServer, which allows us to provide - # maximum size for a single cache entry. - # - ns_cache_create \ - -maxentry 200000 \ - xotcl_object_cache \ - [parameter::get_from_package_key \ - -package_key xotcl-core \ - -parameter XOTclObjectCacheSize \ - -default 400000] - } else { - # - # Version for AOLserver - # - ns_cache create xotcl_object_cache \ - -size [parameter::get_from_package_key \ - -package_key xotcl-core \ - -parameter XOTclObjectCacheSize \ - -default 400000] - } + ::xo::Cache create ::xo::xotcl_object_cache \ + -maxentry 200000 \ + -package_key xotcl-core \ + -parameter XOTclObjectCacheSize \ + -default_size 400000 - ns_cache create xotcl_object_type_cache \ - -size [parameter::get_from_package_key \ - -package_key xotcl-core \ - -parameter XOTclObjectTypeCacheSize \ - -default 50000] - ns_cache create xotcl_package_cache \ - -size [parameter::get_from_package_key \ - -package_key xotcl-core \ - -parameter XOTclPackageCacheSize \ - -default 10000] + ::xo::Cache create xotcl_object_type_cache \ + -package_key xotcl-core \ + -parameter XOTclObjectTypeCacheSize \ + -default_size 50000 + + ::xo::Cache create xotcl_package_cache \ + -package_key xotcl-core \ + -parameter XOTclPackageCacheSize \ + -default_size 10000 } ad_proc -deprecated has_ltree {} { Check, whether ltree is available (postgres only) + @see ::xo::dc has_ltree } { ::xo::dc has_ltree } ad_proc -deprecated has_hstore {} { Check, whether hstore is available (postgres only) + @see ::xo::dc has_hstore } { ::xo::dc has_hstore } Index: openacs-4/packages/xotcl-core/tcl/cr-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/cr-procs.tcl,v diff -u -N -r1.65 -r1.66 --- openacs-4/packages/xotcl-core/tcl/cr-procs.tcl 11 Jun 2018 09:11:08 -0000 1.65 +++ openacs-4/packages/xotcl-core/tcl/cr-procs.tcl 21 Jun 2018 09:19:51 -0000 1.66 @@ -1019,8 +1019,8 @@ -revision_id $revision_id \ -publish_status $publish_status \ -is_latest $is_latest - ::xo::clusterwide ns_cache flush xotcl_object_cache ::${:item_id} - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$revision_id + ::xo::xotcl_object_cache flush ::${:item_id} + ::xo::xotcl_object_cache flush ::$revision_id } CrItem ad_instproc update_item_index {} { @@ -1548,7 +1548,7 @@ -folder_id ${:folder_id} \ -content_types [[self class] set allowed_content_types] } - ::xo::clusterwide ns_cache flush xotcl_object_cache ::${:parent_id} + ::xo::xotcl_object_cache flush ::${:parent_id} # who is setting sub_folder_list? #db_flush_cache -cache_key_pattern sub_folder_list_* return ${:folder_id} @@ -1626,7 +1626,7 @@ CrCache instproc delete {-item_id} { next - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$item_id + ::xo::xotcl_object_cache flush ::$item_id # we should probably flush as well cached revisions } @@ -1697,7 +1697,7 @@ # cache only names with IDs set obj [self] set canonical_name ::[$obj item_id] - ::xo::clusterwide ns_cache flush xotcl_object_cache $obj + ::xo::xotcl_object_cache flush $obj if {$obj eq $canonical_name} { # :log "--CACHE saving $obj in cache" # @@ -1719,14 +1719,14 @@ # # In any case, flush the canonical name. # - ::xo::clusterwide ns_cache flush xotcl_object_cache $canonical_name + ::xo::xotcl_object_cache flush $canonical_name } # To be on he safe side, delete the revison as well from the # cache, if possible. if {[$obj exists revision_id]} { set revision_name ::[$obj revision_id] if {$obj ne $revision_name} { - ::xo::clusterwide ns_cache flush xotcl_object_cache $revision_name + ::xo::xotcl_object_cache flush $revision_name } } } @@ -1755,7 +1755,7 @@ return $item_id } CrCache::Item instproc delete args { - ::xo::clusterwide ns_cache flush xotcl_object_cache [self] + ::xo::xotcl_object_cache flush [self] # :msg "delete flush xotcl_object_type_cache ${:parent_id}-[:name]" ::xo::clusterwide ns_cache flush xotcl_object_type_cache ${:parent_id}-[:name] next Index: openacs-4/packages/xotcl-core/tcl/object-cache-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/Attic/object-cache-init.tcl,v diff -u -N --- openacs-4/packages/xotcl-core/tcl/object-cache-init.tcl 7 Aug 2017 23:48:30 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,20 +0,0 @@ -# The following two commands to setup the cache were moved to -# generic-procs due to problems with install.xml -# -# -# ns_cache create xotcl_object_cache -size 200000 -# ns_cache create xotcl_object_type_cache -size 10000 - -#ns_cache create xotcl_object_cache -size 200000 -#ns_cache create xotcl_object_type_cache -size 10000 - -# should provide parameter at some time... - -# [parameter::get -package_id [ad_acs_kernel_id] -parameter MaxSize -default 200000] - - -# Local variables: -# mode: tcl -# tcl-indent-level: 2 -# indent-tabs-mode: nil -# End: Index: openacs-4/packages/xowiki/tcl/package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/package-procs.tcl,v diff -u -N -r1.319 -r1.320 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 20 May 2018 11:01:57 -0000 1.319 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 21 Jun 2018 09:19:51 -0000 1.320 @@ -1985,7 +1985,7 @@ @return folder_id } { - set folder_id [ns_cache eval xotcl_object_type_cache root_folder-${:id} { + set folder_id [ns_cache eval xotcl_package_cache root_folder-${:id} { set folder_id [::xo::db::CrClass lookup -name $name -parent_id $parent_id] if {$folder_id == 0} { @@ -2417,8 +2417,8 @@ } Package instproc delete_revision {-revision_id:required -item_id:required} { - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$item_id - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$revision_id + ::xo::xotcl_object_cache flush ::$item_id + ::xo::xotcl_object_cache flush ::$revision_id ::xo::db::sql::content_revision del -revision_id $revision_id } @@ -2567,7 +2567,7 @@ :flush_references -item_id $item_id -name $name -parent_id $parent_id :flush_page_fragment_cache -scope agg - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$item_id + ::xo::xotcl_object_cache flush ::$item_id # # Clear potentially cached revisions. The function could be @@ -2577,7 +2577,7 @@ foreach revision_id [::xo::dc list get_revisions { select revision_id from cr_revisions where item_id = :item_id }] { - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$revision_id + ::xo::xotcl_object_cache flush ::$revision_id } } 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 -N -r1.525 -r1.526 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 11 Jun 2018 18:47:26 -0000 1.525 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 21 Jun 2018 09:19:52 -0000 1.526 @@ -3643,7 +3643,7 @@ $payload init } on error {errorMsg} { ad_log error "xowiki::Object set_payload: content $cmd lead to error: $errorMsg" - ::xo::clusterwide ns_cache flush xotcl_object_cache ${:item_id} + ::xo::xotcl_object_cache flush ::${:item_id} } } Index: openacs-4/packages/xowiki/tcl/xowiki-utility-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-utility-procs.tcl,v diff -u -N -r1.50 -r1.51 --- openacs-4/packages/xowiki/tcl/xowiki-utility-procs.tcl 17 May 2018 14:02:52 -0000 1.50 +++ openacs-4/packages/xowiki/tcl/xowiki-utility-procs.tcl 21 Jun 2018 09:19:52 -0000 1.51 @@ -484,9 +484,9 @@ ::xo::dc dml chg5 "update acs_objects set object_type = '::xowiki::FormPage' where object_id = :revision_id" ::xo::dc dml chg6 "update cr_items set content_type = '::xowiki::FormPage', publish_status = 'ready', live_revision = :revision_id, latest_revision = :revision_id where item_id = :item_id" - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$package_id - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$item_id - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$revision_id + ::xo::xotcl_object_cache flush ::$package_id + ::xo::xotcl_object_cache flush ::$item_id + ::xo::xotcl_object_cache flush ::$revision_id ::xo::clusterwide ns_cache flush xotcl_object_type_cache root-folder-$package_id ::xo::clusterwide ns_cache flush xotcl_object_type_cache $item_id ::xo::clusterwide ns_cache flush xotcl_object_type_cache $revision_id @@ -821,8 +821,8 @@ #ns_log notice "--cpo UPDATE $page_id new_page_order $new_page_order" $temp_obj item_id $item_id $temp_obj update_attribute_from_slot -revision_id $page_id $slot $new_page_order - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$item_id - ::xo::clusterwide ns_cache flush xotcl_object_cache ::$page_id + ::xo::xotcl_object_cache flush ::$item_id + ::xo::xotcl_object_cache flush ::$page_id } } #