Help us shape the future of Go! Take the 2026 Go Developer Survey

timecache

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Now

func Now() time.Time

Now returns the cached current time.

func Set

func Set(timeCache *TimeCache)

Set sets the global time cache instance.

Types

type TimeCache

type TimeCache struct {
	// contains filtered or unexported fields
}

TimeCache stores the current time and updates it periodically.

func New

func New(interval time.Duration) *TimeCache

New returns a new TimeCache instance with the specified interval.

The interval parameter specifies the duration between cache refreshes. If interval is 0, it defaults to 1 second; if it's less than 1 millisecond, it defaults to 1 millisecond. *TimeCache.

func (*TimeCache) Close added in v0.9.0

func (tc *TimeCache) Close()

Close stops the periodic update of the time cache.

func (*TimeCache) Now

func (tc *TimeCache) Now() time.Time

Now returns the current time from the TimeCache instance.

No parameters. Returns a time.Time value representing the current time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL