QueryCountCache
The count cache of snapshot queries: the counts of QueryGateway.count queries, and the totals of QueryGateway.paged ones when QueryCountCacheOptions.pagedTotals says so, shared by the gateways of a node. A cached count may lag the rows by up to QueryCountCacheOptions.ttl after another node's write.
Key: the aggregate type, the admitted filter (the query as admission rewrote it, with every value and the scope and tenant conditions the policies appended: the full query fingerprint, not its value-free shape) and the bound (
nullfor an exact count), with the caller's tenant (or cross-tenant reach), owner, space and stated scope besides. A count is never served to another scope or tenant, and a count and a paged total of one filter and bound share an entry.Validity: the checkpoint of the type, read before counting: an entry is served while the checkpoint still reads the value it was counted at, and for at most QueryCountCacheOptions.ttl. A write that lands while the count runs moves the checkpoint past the value the entry carries, so the next query counts again.
Failure: when the checkpoint cannot be read, the query counts without the cache.
ticker reads nanoseconds, monotonic: the time an entry ages by.