config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config holds server settings. Values come from defaults, then an optional config file ("key value" per line, like redis.conf), then command-line flags (--key value). CONFIG SET can change most values at runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBytes

func ParseBytes(s string) (int64, error)

ParseBytes accepts plain numbers or units: 100mb, 1gb, 512kb.

Types

type Config

type Config struct {
	Bind     string
	Port     int
	HTTPPort int // REST + WebSocket + dashboard; 0 disables
	Shards   int // keyspace shards (power of two)

	RequirePass string
	MaxClients  int
	Timeout     int // idle client timeout in seconds; 0 = never

	MaxMemory        int64  // bytes; 0 = unlimited
	MaxMemoryPolicy  string // noeviction, {allkeys,volatile}-{lru,lfu,tinylfu,random}, volatile-ttl
	MaxMemorySamples int
	HZ               int // background task frequency (active expiry etc.)

	Dir                      string
	DBFilename               string
	Save                     []SaveRule
	AppendOnly               bool
	AppendFilename           string
	AppendFsync              string // always, everysec, no
	AutoAOFRewritePercentage int
	AutoAOFRewriteMinSize    int64

	CompressionThreshold int // compress string values >= this many bytes; 0 = off
	HistoryDepth         int // versions kept per string key; 0 = off

	ReplicaOf  string // "host port" or "" for leader
	MasterAuth string // password used to authenticate to the leader
	MasterUser string // ACL user for MasterAuth ("" = default)
	// ReplBacklogSize is how many bytes of recent writes a leader keeps so a
	// reconnecting replica can catch up without a full resync.
	ReplBacklogSize int64

	ClusterEnabled bool
	ClusterNodeID  string
	ClusterNodes   []string // "id host:port slotStart-slotEnd"
	RaftPort       int
	RaftPeers      []string // "id raftHost:raftPort dataHost:dataPort"

	SlowlogLogSlowerThan int64 // microseconds; <0 disables
	SlowlogMaxLen        int

	ScriptTimeoutMs int
	LogLevel        string
}

func Default

func Default() *Config

func (*Config) ApplyArgs

func (c *Config) ApplyArgs(args []string) error

ApplyArgs applies "--key value [value...]" style arguments.

func (*Config) Load

func (c *Config) Load(path string) error

Load reads a config file into c.

func (*Config) Params

func (c *Config) Params(pattern string) [][2]string

Params returns parameter name → value for CONFIG GET, filtered by a glob pattern.

type SaveRule

type SaveRule struct {
	Seconds int
	Changes int
}

SaveRule triggers a snapshot after Seconds if at least Changes writes happened.

type Store

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

Store gives lock-free reads of an immutable snapshot; Set swaps in a copy.

func NewStore

func NewStore(c *Config) *Store

func (*Store) Get

func (s *Store) Get() *Config

Get returns the current config. Never modify the returned value.

func (*Store) Set

func (s *Store) Set(name, value string) error

Set changes one parameter at runtime (CONFIG SET).

Jump to

Keyboard shortcuts

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