template::get_cached_result (private)

 template::get_cached_result name type

Defined in packages/acs-templating/tcl/query-procs.tcl

Looks in the appropriate cache for the named query result If a valid result is found, then sets the result in the returning stack frame.

Parameters:
name (required)
Name of cached result-set
type (required)
Type of query
Returns:
1 if result was successfully retrieved, 0 if failed

Partial Call Graph (max 5 caller/called nodes):
%3 template::query template::query (public) template::get_cached_result template::get_cached_result template::query->template::get_cached_result acs::clusterwide acs::clusterwide template::get_cached_result->acs::clusterwide template::multirow template::multirow (public) template::get_cached_result->template::multirow

Testcases:
No testcase defined.
Source code:

    upvar opts opts
    set cache_key $opts(cache)
    set success 0

    if { [info exists opts(persistent)] } {

        if { [ns_cache names template_query_cache $cache_key] ne ""} {

            if {[ns_info name] eq "NaviServer"} {
                set cached_result ""
                ns_cache_get template_query_cache $cache_key cached_result
            } else {

                # get the pair of the timeout and value
                lassign [ns_cache get template_query_cache $cache_key] timeout cached_result

                # check the timeout
                if { $timeout > [ns_time] } {
                    set success 1
                } else {
                    acs::clusterwide ns_cache flush template_query_cache $cache_key
                }
            }
        }

    } else {
        if { [info exists ::__template_query_request_cache($cache_key)] } {
            set cached_result $::__template_query_request_cache($cache_key)
            set success 1
        }
    }

    if { $success } {

        switch -- $type {

            multirow {

                upvar $opts(uplevel) $name:rowcount rowcount
                set rowcount [llength $cached_result]
                set rownum 1

                foreach cached_row $cached_result {
                    upvar $opts(uplevel) $name:$rownum row
                    array set row $cached_row
                    incr rownum
                }
                set opts(result) ""
            }
            onerow {

                upvar $opts(uplevel) $name result
                array set result $cached_result
                set opts(result) ""
            }
            default {

                upvar $opts(uplevel) $name result
                set result $cached_result
                set opts(result) $cached_result
            }
        }
    }

    return $success
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: