redisserver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenEngine

func OpenEngine(cfg Config) (kvstore.DB, error)

OpenEngine opens the configured backend and returns a kvstore wrapper.

Types

type Config

type Config struct {
	Addr string
	Dir  string

	Engine string // "hashdb" or "treedb"

	// Authentication. Empty means AUTH is not required.
	Auth string

	// Batch SET optimization (benchmark-focused).
	BatchSets             bool
	BatchSize             int
	BatchFlushOnNonset    bool
	BatchFlushOnNonsetSet bool

	// HashDB options.
	HashDBShards      int
	HashDBCompression bool

	// TreeDB options.
	TreeDBFlushThreshold    int64
	TreeDBValueLogThreshold int
	TreeDBDisableWAL        bool
	TreeDBRelaxedSync       bool
	TreeDBJournalLanes      int
	TreeDBMemtableShards    int

	// TreeDB compaction defaults (used by COMPACT/BGREWRITEAOF).
	CompactDeadRatio         float64
	CompactMinBytes          uint64
	CompactMaxSlabs          int
	CompactMicroBatch        int
	CompactRotateBeforeWrite bool
	CompactCopyBytesPerSec   int64
	CompactCopyBurstBytes    int64

	// Optional custom logger. If nil, the default logger is used.
	Logf func(format string, args ...any)

	// Optional server-level timeout for idle clients.
	IdleClose time.Duration
}

Config controls server behavior and engine selection.

type Server

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

Server implements a Redis-compatible server backed by TreeDB or HashDB.

func New

func New(cfg Config) (*Server, error)

New creates a configured server and opens the backing engine.

func (*Server) Addr

func (s *Server) Addr() net.Addr

Addr returns the bound address if the server is listening.

func (*Server) Close

func (s *Server) Close() error

Close stops the server and closes the backing engine.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts serving on the configured address.

func (*Server) Serve

func (s *Server) Serve(ln net.Listener) error

Serve starts serving on the provided listener (useful for tests).

Jump to

Keyboard shortcuts

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