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

redisengine

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package redisengine runs an in-process Redis-protocol server (miniredis) on an allocator-provided or ephemeral port.

Index

Constants

This section is empty.

Variables

View Source
var ErrBadSnapshot = errors.New("invalid engine snapshot data")

ErrBadSnapshot is returned when snapshot data cannot be decoded.

Functions

func DumpKeyspace

func DumpKeyspace(mr *miniredis.Miniredis) ([]byte, error)

DumpKeyspace is Snapshot for a bare miniredis server. A nil server yields nil.

func LoadKeyspace

func LoadKeyspace(mr *miniredis.Miniredis, data []byte) error

LoadKeyspace is Restore for a bare miniredis server.

Types

type Engine

type Engine struct {
	Mini *miniredis.Miniredis

	Host          string
	Port          int
	AllocatedPort int
	// contains filtered or unexported fields
}

Engine is a running in-process Redis-protocol server.

func Start

func Start(alloc *portalloc.Allocator, label string) (*Engine, error)

Start launches a server. With a non-nil allocator the port is acquired from it under label and bound on all interfaces; otherwise an ephemeral loopback port is used.

func (*Engine) Addr

func (e *Engine) Addr() string

Addr returns the connectable host:port.

func (*Engine) Close

func (e *Engine) Close()

Close stops the server and releases its allocated port. Nil-safe and idempotent.

func (*Engine) Restore

func (e *Engine) Restore(data []byte) error

Restore loads a blob produced by Snapshot into the engine, overwriting existing keys of the same name. Empty data is a no-op.

func (*Engine) Snapshot

func (e *Engine) Snapshot() ([]byte, error)

Snapshot serialises the keyspace (strings, hashes, lists, sets, sorted sets, streams, key and hash-field TTLs) into a gzip'd opaque blob. Returns nil when the engine holds no keys. HyperLogLog keys and stream consumer groups are not captured.

Jump to

Keyboard shortcuts

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