%3 ::acs::PartitionedCache ::acs::PartitionedCache cache_name flush_all flush_pattern_in_all_partitions init show_all ::acs::Cache ::acs::Cache cache_create cache_name eval flush flush_all flush_cache flush_pattern get get_size init set show_all ::acs::PartitionedCache->::acs::Cache ::acs::KeyPartitionedCache ::acs::KeyPartitionedCache flush_pattern set ::acs::KeyPartitionedCache->::acs::PartitionedCache ::acs::HashKeyPartitionedCache ::acs::HashKeyPartitionedCache cache_name flush_pattern set ::acs::HashKeyPartitionedCache->::acs::KeyPartitionedCache

Class ::acs::PartitionedCache

::acs::PartitionedCache[i] create ... \
           [ -default_size (default "100KB") ] \
           [ -maxentry:integer maxentry:integer ] \
           [ -name name ] \
           [ -package_key:required package_key:required ] \
           [ -parameter:required parameter:required ] \
           [ -partitions:integer (default "1") ] \
           [ -timeout (default "5m") ]

Partitioned cache infrastructure. Partition numbers are computed via a modulo function from the numeric keys.
Defined in packages/acs-tcl/tcl/acs-cache-procs.tcl

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::acs::Cache[i]
  • subclass: ::acs::KeyPartitionedCache[i]
::nx::Class create ::acs::PartitionedCache \
     -superclass ::acs::Cache

Methods (to be applied on instances)

  • flush_all (scripted, public)

     <instance of acs::PartitionedCache[i]> flush_all \
        [ -partition_key partition_key ]

    Flush all entries in all partitions of a cache.

    Switches:
    -partition_key (optional)

    Testcases:
    No testcase defined.
    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]"
    }
  • init (scripted, public)

     <instance of acs::PartitionedCache[i]> init

    If the name was not provided, use the object name as default for the cache name.

    Testcases:
    No testcase defined.
    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
    }
  • show_all (scripted, public)

     <instance of acs::PartitionedCache[i]> show_all

    Log all cache keys of all partitions to the system log. The primary usage is for debugging.

    Testcases:
    No testcase defined.
    for {set i 0} {$i < ${:partitions}} {incr i} {
        ns_log notice "content of ${:name}-$i: [ns_cache_keys ${:name}-$i]"
    }