Class ::acs::PartitionedCache (public)
::nx::Class ::acs::PartitionedCache
Defined in packages/acs-tcl/tcl/acs-cache-procs.tcl
Partitioned cache infrastructure. Partition numbers are computed via a modulo function from the numeric keys.
- Testcases:
- No testcase defined.
Source code: :property {partitions:integer 1} :protected method cache_name {key:integer} { # # Return the cache_name always as the same Tcl_Obj (list # element) rather than concatenating always a fresh # Tcl_Obj dynamically the fly (type string). Caching the # cache structure in the dynamic Tcl_Obj can't not work. # return [lindex ${:partition_names} [expr {$key % ${:partitions}}]] } :public method init {} { # # If the name was not provided, use the object name as # default for the cache name. # if {![info exists :name]} { set :name [namespace tail [current]] } set :partitions [::parameter::get_from_package_key -package_key ${:package_key} -parameter "${:parameter}Partitions" -default ${:partitions}] # # Create multiple separate caches depending on the # partitions. A PartitionedCache requires to have a # partitioning function that determines the nth partition # number from some partition_key. # set size [expr {[:get_size] / ${:partitions}}] set :partition_names {} for {set i 0} {$i < ${:partitions}} {incr i} { lappend :partition_names ${:name}-$i :cache_create ${:name}-$i $size } } :public method flush_all {{-partition_key ""}} { # # Flush all entries in all partitions of a cache. # for {set i 0} {$i < ${:partitions}} {incr i} { ::acs::clusterwide ns_cache_flush ${:name}-$i #ns_log notice "flush_all: ns_cache_flush ${:name}-$i" #ns_log notice "... content of ${:name}-$i: [ns_cache_keys ${:name}-$i]" } } :method flush_pattern_in_all_partitions {pattern} { # # Flush matching entries in all partitions of a cache based on # a pattern. # for {set i 0} {$i < ${:partitions}} {incr i} { ::acs::clusterwide ns_cache_flush -glob ${:name}-$i $pattern ns_log notice "flush_pattern_in_all_partitions: ns_cache_flush ${:name}-$i $pattern" #ns_log notice "... content of ${:name}-$i: [ns_cache_keys ${:name}-$i]" } } :public method show_all {} { # # Log all cache keys of all partitions to the system # log. The primary usage is for debugging. # for {set i 0} {$i < ${:partitions}} {incr i} { ns_log notice "content of ${:name}-$i: [ns_cache_keys ${:name}-$i]" } }XQL Not present: Generic, PostgreSQL, Oracle