clock

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package clock provides a time abstraction so cache internals can be tested without sleeping or time.Sleep-based races.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock is the interface used internally by cache to read the current time.

type Mock

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

Mock is a controllable clock for tests.

func NewMock

func NewMock(t time.Time) *Mock

func (*Mock) Advance

func (m *Mock) Advance(d time.Duration)

Advance moves the mock clock forward by d.

func (*Mock) Now

func (m *Mock) Now() time.Time

func (*Mock) Set

func (m *Mock) Set(t time.Time)

Set sets the mock clock to t.

type Real

type Real struct{}

Real is the production clock, delegates to time.Now().

func (Real) Now

func (Real) Now() time.Time

Jump to

Keyboard shortcuts

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