fakeredis

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fakeredis is a tiny RESP2 fake server used by celeris middleware tests that adapt onto the native driver/redis client. Not for production use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is a minimal in-process RESP2 server that implements a subset of commands sufficient for middleware store adapters: GET, SET, DEL, SETEX, EXPIRE, PEXPIRE, TTL, PTTL, EXISTS, GETDEL, SCAN, HMSET, HMGET, HGET, HSET, HEXPIRE, PING, AUTH, HELLO, SELECT, SCRIPT LOAD, EVAL, EVALSHA.

Use Start to spin one up on a random loopback port; the testing.TB Cleanup hook closes the listener when the test ends.

func Start

func Start(tb testing.TB) *Server

Start returns a running fake bound to a random loopback port.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns "host:port".

func (*Server) Data

func (s *Server) Data() map[string]string

Data returns a copy of current string-keyed entries. For test assertions only.

func (*Server) Hash

func (s *Server) Hash(key string) map[string]string

Hash returns a snapshot of the given hash key's fields. Returns nil if the key does not exist.

func (*Server) SetScript

func (s *Server) SetScript(sha, body string)

SetScript pre-registers a Lua script under its expected SHA. Tests that stub out EVALSHA replies can inject known SHAs this way.

Jump to

Keyboard shortcuts

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