redisutil

package
v0.0.50-alpha.127 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 4 modules, 8 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

Index

Constants

View Source
const (
	ClusterMode    = "cluster"    // Cluster mode for Redis.
	SentinelMode   = "sentinel"   // Sentinel mode for Redis.
	StandaloneMode = "standalone" // Standalone mode for Redis.
)

RedisMode

Variables

This section is empty.

Functions

func Check

func Check(ctx context.Context, config *Config) error

CheckRedis checks the Redis connection.

func NewRedisClient

func NewRedisClient(ctx context.Context, config *Config) (redis.UniversalClient, error)

Types

type Config

type Config struct {
	RedisMode string             // RedisMode can be "cluster", "sentinel", or "standalone".
	Address   []string           // List of Redis server addresses (host:port).
	Username  string             // Username for Redis authentication (Redis 6 ACL).
	Password  string             // Password for Redis authentication.
	MaxRetry  int                // Maximum number of retries for a command.
	DB        int                // Database number to connect to, for non-cluster mode.
	PoolSize  int                // Number of connections to pool.
	TLS       *xtls.ClientConfig // TLS configuration for secure connections.
	Sentinel  *Sentinel          // Sentinel configuration for high availability.
}

Config defines the configuration parameters for a Redis client, including options for both single-node and cluster mode connections.

type Sentinel

type Sentinel struct {
	MasterName     string   `json:"masterName" yaml:"masterName" config:"allowempty"`
	SentinelAddrs  []string `json:"sentinelAddrs" yaml:"sentinelAddrs" config:"allowempty"`
	RouteByLatency bool     `json:"routeByLatency" yaml:"routeByLatency" config:"allowempty"` // Route by latency if true.
	RouteRandomly  bool     `json:"routeRandomly" yaml:"routeRandomly" config:"allowempty"`   // Route randomly if true.
}

Jump to

Keyboard shortcuts

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