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

cachetest

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package cachetest 是 data 门面子包:CacheAside 实现契约测试套件(8 场景,含 -race)。

re-export 自 github.com/oekit/pkg/cache/cachetest:类型为泛型 type alias(与源包**完全同一类型**, 双向赋值互通);非泛型函数/变量经 var 引用同一函数值。源包新增导出符号时 本壳需同步(门面跟版税,data 门面化决策已接受)。

Index

Constants

This section is empty.

Variables

View Source
var NewFakeClock = src.NewFakeClock

NewFakeClock 创建起点为 2026-01-01T00:00:00Z 的假时钟。

Functions

func Run

func Run[T any](t *testing.T, c Contract[T], factory func(t *testing.T, source pkgcache.SourceFunc[T]) pkgcache.CacheAside[T])

Run 跑完整契约场景(8 个子测试)。

func RunWithClock added in v0.11.0

func RunWithClock[T any](t *testing.T, c Contract[T], factory ClockFactory[T])

RunWithClock 跑时钟驱动的 TTL 边界场景(4 子测试:过期闭边界/TTL=0 永不过期/ null marker 过窗重源/重写刷新过期)。

Types

type ClockFactory added in v0.11.0

type ClockFactory[T any] = src.ClockFactory[T]

ClockFactory 是支持时钟注入的缓存工厂形态:实现把 clock.Now 路由到全部 TTL 判定。

type Contract

type Contract[T any] = src.Contract[T]

func Comparable

func Comparable[T comparable]() Contract[T]

Comparable 返回可比较类型的现成 Contract。

type FakeClock added in v0.11.0

type FakeClock = src.FakeClock

FakeClock 是套件提供的假时钟(并发安全;测试内手动推进)——供时钟注入实现 接入 RunWithClock 假时钟 TTL 套件(pkg v0.13.0)。

Jump to

Keyboard shortcuts

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