acs::Cache method eval (public)
<instance of acs::Cache> eval [ -partition_key partition_key ] \ [ -expires expires ] [ -timeout timeout ] [ -per_request ] key \ command
Defined in packages/acs-tcl/tcl/acs-cache-procs.tcl
Evaluate the command unless the result was already computed before and cached.
- Switches:
- -partition_key (optional)
- Used for determining the cache name in partitioned caches. The partition key is computed typically automatically depending on the cache type.
- -expires (optional)
- Lifetime of the cache entry. The entry will be purged automatically when the time is reached. The time is in seconds unless a time unit is specified (e.g., 5m)
- -timeout (optional)
- Maximum time to wait for the command to complete. The time is in seconds unless a time unit is specified (e.g., 2.5m)
- -per_request (optional)
- When set, cache the result per request. So far, no attempt is made to flush the result during the lifetime of the request.
- Parameters:
- key (required)
- The cache key
- command (required)
- The command to be executed when the result is not yet cached.
- Testcases:
- No testcase defined.
Source code: if {![info exists partition_key]} { set partition_key $key } foreach optional_parameter {expires timeout} { if {[info exists $optional_parameter]} { set ${optional_parameter}_flag [list -$optional_parameter [set $optional_parameter]] } else { set ${optional_parameter}_flag "" } } set cache_name [:cache_name $partition_key] try { if {$per_request} { acs::per_request_cache eval -key ::acs-${cache_name}($key) { :uplevel [list ns_cache_eval {*}$expires_flag {*}$timeout_flag -- $cache_name $key $command] } } else { :uplevel [list ns_cache_eval {*}$expires_flag {*}$timeout_flag -- $cache_name $key $command] } } on break {r} { # # When the command ends with "break", it means: # "don't cache". We return in this case always a # 0. # #ns_log notice "====================== [self] $key -> break -> <$r>" return 0 } on ok {r} { return $r }XQL Not present: Generic, PostgreSQL, Oracle