redis

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Client *redis.Client

Client is the global Redis client instance. Backed by either a single-node client or a Sentinel failover client — callers use the same interface either way.

Functions

func Close

func Close() error

Close closes the Redis connection gracefully.

func Connect

func Connect(cfg Config) error

Connect establishes a connection to Redis. When cfg.SentinelAddrs is set it connects via Sentinel for HA failover. Otherwise it falls back to the single-instance URL.

func Health

func Health() error

Health checks the Redis connection health.

Types

type Config

type Config struct {
	URL            string // single-instance URL (redis://[:password@]host:port/db)
	SentinelAddrs  string // comma-separated sentinel host:port list
	SentinelMaster string // sentinel master name (default: "mymaster")
	Password       string // shared password for both modes
}

Config holds Redis configuration. If SentinelAddrs is non-empty, Sentinel (HA) mode is used and URL is ignored.

Jump to

Keyboard shortcuts

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