clients

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAllClients added in v1.0.1

func CloseAllClients()

CloseAllClients closes all pooled Redis clients for graceful shutdown.

func CreateDirectClient added in v1.1.0

func CreateDirectClient(endpoint *config.RedisEndpoint, addr string) (*redis.Client, error)

CreateDirectClient creates a standalone client connected directly to a specific address, inheriting credentials and TLS settings from the endpoint.

func CreateRedisClient

func CreateRedisClient(endpoint *config.RedisEndpoint) (*redis.Client, error)

CreateRedisClient creates a new standalone Redis client from an endpoint configuration.

func CreateRedisClientFromURL deprecated

func CreateRedisClientFromURL(url string, password string, db int) (*redis.Client, error)

Deprecated: Use GetRedisClient for pooled clients.

func DetectClusterMode added in v1.1.0

func DetectClusterMode(ctx context.Context, endpoint *config.RedisEndpoint) (bool, error)

DetectClusterMode connects to the endpoint and checks redis_mode.

func ForEachMaster added in v1.1.0

func ForEachMaster(ctx context.Context, endpoint *config.RedisEndpoint, fn func(ctx context.Context, client *redis.Client, addr string) error) error

ForEachMaster executes fn on each master node in a cluster. For standalone Redis, fn is called once on the single node. Errors from individual nodes are collected and returned as a combined error.

func GetRedisClient added in v1.0.1

func GetRedisClient(url string, password string, db int) (*redis.Client, error)

GetRedisClient returns a pooled standalone Redis client for the given (url, password, db) combination. The returned client must NOT be closed — it is shared and long-lived.

func GetRedisInfo

func GetRedisInfo(ctx context.Context, client redis.Cmdable, section string) (map[string]string, error)

GetRedisInfo retrieves Redis INFO command output.

func PingRedis

func PingRedis(ctx context.Context, client redis.Cmdable) error

PingRedis checks if a Redis connection is working.

func ScanAllKeys added in v1.1.0

func ScanAllKeys(ctx context.Context, endpoint *config.RedisEndpoint, pattern string, maxKeys int) ([]string, error)

ScanAllKeys scans keys matching pattern across all master nodes in a cluster, or on the single node for standalone Redis. Returns deduplicated keys.

Types

type ClusterNodeInfo added in v1.1.0

type ClusterNodeInfo struct {
	ID    string
	Addr  string // host:port
	Role  string // "master" or "slave"
	Flags string
}

ClusterNodeInfo represents a node parsed from CLUSTER NODES output.

func GetMasterNodes added in v1.1.0

func GetMasterNodes(ctx context.Context, endpoint *config.RedisEndpoint) ([]ClusterNodeInfo, bool, error)

GetMasterNodes returns ClusterNodeInfo for each master in the cluster. For standalone endpoints it returns a single entry for the configured endpoint.

func ParseClusterNodes added in v1.1.0

func ParseClusterNodes(ctx context.Context, client *redis.Client) ([]ClusterNodeInfo, error)

ParseClusterNodes runs CLUSTER NODES and parses the output.

Jump to

Keyboard shortcuts

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