MCPcopy
hub / github.com/unkeyed/unkey / CachedClock

Struct CachedClock

pkg/clock/cached_clock.go:14–19  ·  view source on GitHub ↗

This clock implementation takes inspiration from https://github.com/agilira/go-timecache but works with our clock.Clock interface CachedClock implements the Clock interface using a cached atomic value to avoid the overhead of system calls from time.Now().

Source from the content-addressed store, hash-verified

12// CachedClock implements the Clock interface using a cached atomic value
13// to avoid the overhead of system calls from time.Now().
14type CachedClock struct {
15 nanos atomic.Int64
16 resolution time.Duration
17 ticker *time.Ticker
18 done chan struct{}
19}
20
21// NewCachedClock creates a new CachedClock that uses the system time cached every [resolution].
22//

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected