Documentation
¶
Overview ¶
Package timekeeper provides a high-performance cached time implementation optimized for high-throughput applications that need fast time access without the overhead of syscalls on every time.Now() call.
This implementation uses atomic operations and periodic updates to provide microsecond-precision cached time values with configurable refresh rates.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Now ¶
Now returns the cached current time using the global cache instance. This is the primary function for high-throughput time access.
func SetRefreshInterval ¶
SetRefreshInterval changes the global cache refresh interval. Use this to tune performance vs precision for your specific workload.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache holds the cached time value and provides thread-safe access
func NewCache ¶
NewCache creates a new time cache with the specified refresh interval. A smaller interval provides more accurate time but uses more CPU. Recommended intervals:
- 1ms for high-precision requirements
- 5ms for balanced performance (default)
- 10-50ms for maximum throughput with lower precision needs
func (*Cache) Now ¶
Now returns the cached current time This is an extremely fast operation using only an atomic load
func (*Cache) SetRefreshInterval ¶
SetRefreshInterval changes the refresh interval dynamically