Documentation
¶
Overview ¶
Package timecache provides a cache for the system clock, to avoid calls to time.Now(). The time is stored as one int64 which holds the number of nanoseconds since the Unix Epoch. The value is accessed using atomic primitives, without locking. The package runs a global singleton TimeCache that is updated every second.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NowUnix ¶
func NowUnix() int64
NowUnix calls TimeCache.NowUnix on the global TimeCache instance.
func NowUnixNano ¶
func NowUnixNano() int64
NowUnixNano calls TimeCache.NowUnixNano on the global TimeCache instance.
Types ¶
type TimeCache ¶
type TimeCache struct {
// contains filtered or unexported fields
}
A TimeCache is a cache for the current system time. The cached time has nanosecond precision.
func New ¶
func New() (tc *TimeCache)
New returns a new TimeCache instance. The TimeCache must be started to update the time.
func (*TimeCache) NowUnixNano ¶
NowUnixNano returns the cached time as nanoseconds since the Unix Epoch.