MCPcopy
hub / github.com/redis/go-redis / getCachedTimeNs

Function getCachedTimeNs

internal/pool/conn.go:37–39  ·  view source on GitHub ↗

getCachedTimeNs returns the current time in nanoseconds. This function previously used a global cache updated by a background goroutine, but that caused unnecessary CPU usage when the client was idle (ticker waking up the scheduler every 50ms). We now use time.Now() directly, which is fast enough on

()

Source from the content-addressed store, hash-verified

35// on modern systems (vDSO on Linux) and only adds ~1-2% overhead in extreme
36// high-concurrency benchmarks while eliminating idle CPU usage.
37func getCachedTimeNs() int64 {
38 return time.Now().UnixNano()
39}
40
41// GetCachedTimeNs returns the current time in nanoseconds.
42// Exported for use by other packages that need fast time access.

Callers 6

GetCachedTimeNsFunction · 0.85
deadlineMethod · 0.85
getConnMethod · 0.85
putConnMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected