testutil

package
v0.8.7 Latest Latest
Warning

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

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

Documentation

Overview

Package testutil provides a shared in-memory core/cache.ExternalCache fake for cache/* package tests. Importable only from packages rooted under cache/, per Go's internal-package visibility rule.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeExternalCache

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

FakeExternalCache is an in-memory, JSON-serializing implementation of core/cache.ExternalCache. Values are marshaled on Set and unmarshaled on Get, matching how the real Redis/Memcached backends behave — a naive map[string]any passthrough would hide (de)serialization bugs.

func NewFakeExternalCache

func NewFakeExternalCache() *FakeExternalCache

NewFakeExternalCache constructs an empty FakeExternalCache.

func (*FakeExternalCache) Del

func (f *FakeExternalCache) Del(_ context.Context, key string) error

func (*FakeExternalCache) DelPrefix

func (f *FakeExternalCache) DelPrefix(_ context.Context, prefix string) error

func (*FakeExternalCache) Get

func (f *FakeExternalCache) Get(_ context.Context, key string, into any) (bool, error)

func (*FakeExternalCache) Keys

func (f *FakeExternalCache) Keys() []string

Keys returns a snapshot of every key currently stored, for assertions on exact key formatting.

func (*FakeExternalCache) Set

func (f *FakeExternalCache) Set(_ context.Context, key string, val any, ttl time.Duration) error

func (*FakeExternalCache) TTL

func (f *FakeExternalCache) TTL(key string) (time.Duration, bool)

TTL returns the TTL passed to the most recent Set for key, and whether the key exists at all.

Jump to

Keyboard shortcuts

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