Class ::acs::SiteNodeUrlspaceCache (public)

 ::nx::Class ::acs::SiteNodeUrlspaceCache[i]

Defined in packages/acs-tcl/tcl/site-nodes-procs.tcl

Cache site-node information via ns_urlspace. We can use the URL trie, which supports tree match operations, for tree information. This means that for example for .vuh handlers it is not necessary to cache the full url for obtaining the site-node, like it was until now: 3839 id-/storage/view/installers/windows-installer/installer.htm 3839 id-/storage/view/aolserver/install.tgz 3839 id-/storage/view/tutorial/OpenACS_Tutorial.htm 3839 id-/storage/view/openacs-dotlrn-conference-2007-spring/Methodology_ALPE.pdf 3839 id-/storage/view/xowiki-resources/Assessment.jpg 3839 id-/storage/view/tutorial-page-map.png ... Providing a single entry like ns_urlspace set -key sitenode /storage/* 3839 is sufficient for replacing all entries above.

Testcases:
No testcase defined.
Source code:
        :public method get_node_id {-url:required} {
            #
            # Get node_id for the provided URL. We have to
            # determine the partial URL for determining the site
            # node.
            #
            # @return node_id (integer)
            #

            #
            # This is the main interface of the
            # SiteNodeUrlspaceCache to provide a first-level
            # cache.
            #

            # Try per-request caching
            #
            if {[dict exists ${:static_site_nodes} $url]} {
                set key :node_id($url)
            } else {
                set key ::__node_id($url)
            }
            if {[info exists $key]} {
                #ns_log notice "==== returning cached value [set $key]"
                return [set $key]
            }

            #
            # Try to get value from urlspace
            #
            set ID [ns_urlspace get -id $::acs::siteNodesID -key sitenode $url]
            if {$ID eq ""} {
                #
                # Get value the classical way, caching potentially
                # the full url path in the site_nodes_id_cache.
                #
                set ID [next]
                #ns_log notice "--- get_node_id from site_nodes_id_cache <$url> -> <$ID>"
                if {$ID ne ""} {
                    #
                    # We got a valid ID. If we would add blindly a
                    # node_id for the returned URL (e.g. for "/*")
                    # and some other subnode is not jet resolved,
                    # we would obtain later the node_id of the
                    # parent_node although there is a subnode.
                    #
                    # We could address this by e.g. pre-caching
                    # all "inner nodes" or similar, but this
                    # requires a deeper analysis of larger sites.
                    #
                    # In earlier versions, we had here
                    #   ... {[site_node::get_children -node_id $ID] eq ""} ...
                    # but on site_node trees with huge number of entries,
                    # this is a waste.
                    #
                    if {![:has_children -node_id $ID]} {
                        #
                        # We are on a leaf-node of the site node
                        # tree. Get the shortened url and save it
                        # in the urlspace.
                        #
                        set short_url [site_node::get_url -node_id $ID]
                        set cmd [list ns_urlspace set -id $::acs::siteNodesID -key sitenode $short_url$ID]
                        #ns_log notice "--- get_node_id save in urlspace <$cmd> -> <$ID>"
                        {*}$cmd
                        #ns_log notice "---\n[join [ns_urlspace list -id $::acs::siteNodesID] \n]"
                    }
                    return [set $key $ID]
                }
            }
            return $ID
        }

        :public method flush_cache {
            -node_id:required,1..1
            {-with_subtree:boolean true}
            {-url ""}
        } {
            #
            # Cleanup in the urlspace tree: Clear always the
            # full subtree via "-recurse" (maybe not always
            # necessary).
            #

            ::acs::clusterwide ns_urlspace unset -id $::acs::siteNodesID -recurse -key sitenode $url
            next
        }
Generic XQL file:
packages/acs-tcl/tcl/site-nodes-procs.xql

PostgreSQL XQL file:
packages/acs-tcl/tcl/site-nodes-procs-postgresql.xql

Oracle XQL file:
packages/acs-tcl/tcl/site-nodes-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: