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 ¶
var ErrBadRDB = errors.New("invalid RDB data")
ErrBadRDB is returned when RDB data is malformed.
var ErrBadSnapshot = errors.New("invalid engine snapshot data")
ErrBadSnapshot is returned when snapshot data cannot be decoded.
var ErrUnsupportedRDB = errors.New("unsupported RDB content")
ErrUnsupportedRDB is returned for RDB content the engine cannot represent.
Functions ¶
func DumpKeyspace ¶
DumpKeyspace is Snapshot for a bare miniredis server. A nil server yields nil.
Types ¶
type Engine ¶
type Engine struct {
Mini *miniredis.Miniredis
// Front relays clients to Mini behind an admit check; nil for ungated engines.
Front *sgfilter.Proxy
// Gate decides Front's admissions; deny-all until Set.
Gate *Gate
Host string
Port int
AllocatedPort int
// contains filtered or unexported fields
}
Engine is a running in-process Redis-protocol server.
func Start ¶
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 StartGated ¶
StartGated is Start with the client-facing port served by a relay in front of a loopback-only server, so Gate can refuse clients. The allocator port (or an ephemeral loopback one) is the relay's.
func (*Engine) Close ¶
func (e *Engine) Close()
Close stops the server and releases its allocated port. Nil-safe and idempotent.
func (*Engine) ExportRDB ¶
ExportRDB serialises the keyspace as a Redis RDB file (version 9). Streams are not representable and fail the export; per-field hash TTLs are dropped because RDB 9 cannot carry them.
func (*Engine) ImportRDB ¶
ImportRDB replaces the keyspace with the contents of an RDB file. Strings, lists, sets, sorted sets and hashes in their plain encodings are supported (with LZF and integer string encodings); compact ziplist, listpack and intset encodings, streams and modules fail with ErrUnsupportedRDB. The keyspace is left untouched on error.
func (*Engine) Restore ¶
Restore loads a blob produced by Snapshot into the engine, overwriting existing keys of the same name. Empty data is a no-op.