template::cache (public)
template::cache command cache_key [ args... ]
Defined in packages/acs-templating/tcl/query-procs.tcl
Generic Caching
- Parameters:
- command (required)
- cache_key (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set result "" switch -exact $command { get { if {[ns_info name] eq "NaviServer"} { # # Get the cache content into variable "result". In case # there is no such entry in the cache, the variable # "result" is not modified. # ns_cache_get template_cache $cache_key result } else { if { [ns_cache names template_cache $cache_key] ne "" } { # get timeout and value lassign [ns_cache get template_cache $cache_key] timeout value # validate timeout if { $timeout > [ns_time] } { set result $value } else { acs::clusterwide ns_cache flush template_cache $cache_key } } } } set { if { [llength $args] == 1 } { set timeout [expr {[ns_time] + 60 * 60 * 24 * 7}] } else { set timeout [expr {[ns_time] + [lindex $args 1]}] } if {[ns_info name] eq "NaviServer"} { # # NaviServer allows per entry expire time # ns_cache_eval -expires $timeout -force template_cache $cache_key set _ [lindex $args 0] } else { # # Use a pair for AOLserver # ns_cache set template_cache $cache_key [list $timeout [lindex $args 0]] } } flush { # The key is actually a string match pattern if {[ns_info name] eq "NaviServer"} { 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" acs::clusterwide ns_cache flush template_cache $name } } } } exists { if {[ns_info name] eq "NaviServer"} { set result [ns_cache_get template_cache $cache_key .] } else { if { [ns_cache get template_cache $cache_key cached_value] } { # get timeout and value lassign $cached_value timeout value # validate timeout if { $timeout > [ns_time] } { set result 1 } else { set result 0 } } else { set result 0 } } } default { error "Invalid command option to template::cache: must be get or set." } } return $resultXQL Not present: Generic, PostgreSQL, Oracle