cachetest

package
v0.0.0-...-e308f56 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Suite

func Suite(t *testing.T, newCache func(t *testing.T) cache.Cache)

Suite runs a comprehensive test suite against a cache.Cache implementation. All cache implementations should pass this test suite to ensure consistent semantics.

Types

type SoakConfig

type SoakConfig struct {
	// Duration is how long to run the soak test (default: 1 minute).
	Duration time.Duration
	// NumObjects is the total number of unique object keys to use (default: 1000).
	NumObjects int
	// MaxObjectSize is the maximum size of each object in bytes (default: 1MB).
	MaxObjectSize int
	// MinObjectSize is the minimum size of each object in bytes (default: 1KB).
	MinObjectSize int
	// OverwritePercent is the percentage of writes that should overwrite existing keys (default: 20).
	OverwritePercent int
	// Concurrency is the number of concurrent goroutines writing to the cache (default: 4).
	Concurrency int
	// TTL is the time-to-live for cache entries (default: 1 hour).
	TTL time.Duration
}

SoakConfig configures the soak test parameters.

type SoakResult

type SoakResult struct {
	Writes       int64
	Reads        int64
	ReadHits     int64
	ReadMisses   int64
	Deletes      int64
	BytesWritten int64
	Duration     time.Duration

	// Memory stats
	HeapAllocStart uint64
	HeapAllocEnd   uint64
	TotalAlloc     uint64
	NumGC          uint32
}

SoakResult contains the results of a soak test run.

func Soak

func Soak(t *testing.T, c cache.Cache, config SoakConfig) SoakResult

Soak runs an extended soak test against a cache implementation.

The test writes random objects of varying sizes, with some overwrites, and verifies that the cache behaves correctly under sustained load. It also performs periodic reads and deletes.

Jump to

Keyboard shortcuts

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