nsmcp::AccessTimeIndex object method slot (public)

 nsmcp::AccessTimeIndex[i] slot key

Defined in /usr/local/ns/tcl/nsmcp/log-traffic-index.tcl

Choose a bounded server-local cache slot.

Parameters:
key (required)
Index key.
Returns:
Slot number.

Testcases:
No testcase defined.
Source code:
scan [string range $key 0 3] %x first
set first [expr {$first % 64}]
# Open addressing avoids losing a live-file index merely because one of
# its rotations hashes to the same slot. The namespace never exceeds 64
# slots, including concurrent writers; replacement only loses acceleration.
for {set i 0} {$i<64} {incr i} {
    set slot [expr {($first+$i)%64}]
    if {[catch {
        nsv_get nsmcp:access-time-index:[ns_info server] $slot
    } entry]
        || [dict get $entry key] eq $key} {
        return $slot
    }
}
return $first
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: