cachefake

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fake

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

Fake exposes a deterministic in-memory store plus assertion helpers for tests. It wraps the memory store so no external services are needed.

func New

func New() *Fake

New creates a Fake using an in-memory store.

func (*Fake) AssertCalled

func (f *Fake) AssertCalled(t *testing.T, op Op, key string, times int)

AssertCalled verifies key was touched by op the expected number of times.

func (*Fake) AssertNotCalled

func (f *Fake) AssertNotCalled(t *testing.T, op Op, key string)

AssertNotCalled ensures key was never touched by op.

func (*Fake) AssertTotal

func (f *Fake) AssertTotal(t *testing.T, op Op, times int)

AssertTotal ensures the total call count for an op matches times.

func (*Fake) Cache

func (f *Fake) Cache() *cache.Cache

Cache returns the cache facade to inject into code under test.

func (*Fake) Count

func (f *Fake) Count(op Op, key string) int

Count returns calls for op+key.

func (*Fake) Reset

func (f *Fake) Reset()

Reset clears recorded counts.

func (*Fake) Total

func (f *Fake) Total(op Op) int

Total returns total calls for an op across keys.

type Op

type Op string

Op identifies a cache operation for assertions.

const (
	OpGet        Op = "get"
	OpSet        Op = "set"
	OpAdd        Op = "add"
	OpInc        Op = "inc"
	OpDec        Op = "dec"
	OpDelete     Op = "delete"
	OpDeleteMany Op = "delete_many"
	OpFlush      Op = "flush"
)

Jump to

Keyboard shortcuts

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