nsmcp::AccessRecordStoreSQLite method capacity (public)

 <instance of nsmcp::AccessRecordStoreSQLite[i]> capacity

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

Report the configured record-store budget and current allocation. Account for the main database and its journal files separately. Writer instances also publish a timestamped capacity snapshot for the status interface.

Returns:
A dictionary containing byte budgets, allocation, disk usage and the limit-exceeded flag.

Testcases:
No testcase defined.
Source code:
set pageSize [${:db} scalar {PRAGMA nsmcp_records.page_size}]
set allocated [expr {wide([${:db} scalar {PRAGMA nsmcp_records.page_count}])*$pageSize}]
set mainLimit [expr {[:accessRecordMainPages ${:settings} $pageSize]*$pageSize}]
set disk [:diskBytes]
set budget [dict get ${:settings} maxBytes]
set result [dict create  maxBytes $budget  mainMaxBytes $mainLimit  mainAllocatedBytes $allocated  diskBytes $disk  limitExceeded [expr {$allocated>$mainLimit || $disk>$budget}]  minimumBudgetBytes [expr {($allocated*5+1)/2}]]
if {${:mode} eq "writer"} {
    nsv_set nsmcp:access-store:[ns_info server] capacitySnapshot  [dict merge $result [dict create observedAt [clock seconds]]]
}
return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: