type Cache struct {
// contains filtered or unexported fields
}
Cache is a single-tenant keycache
it is sharded for 2 reasons:
* more granular GC (eg. less latency perceived by caller)
* mild space savings cause keys are 1 byte shorter
We shard on the first byte of the metric key, which we assume
is evenly distributed.
Duration is a compact way to represent a duration
bucketed in 10 minutely buckets.
which allows us to cover a timeframe of 42 hours
(just over a day and a half)
because:
6 (10m periods per hour) *42 (hours) = 252 (10m periods)
type Shard struct {
sync.Mutex// contains filtered or unexported fields
}
Shard tracks for each SubKey when it was last seen
we know the last seen timestamp with ~10 minute precision
because all SubKey's Duration's are relative to the ref