Documentation
¶
Index ¶
- func CloseAllClients()
- func CreateDirectClient(endpoint *config.RedisEndpoint, addr string) (*redis.Client, error)
- func CreateRedisClient(endpoint *config.RedisEndpoint) (*redis.Client, error)
- func CreateRedisClientFromURL(url string, password string, db int) (*redis.Client, error)deprecated
- func DetectClusterMode(ctx context.Context, endpoint *config.RedisEndpoint) (bool, error)
- func ForEachMaster(ctx context.Context, endpoint *config.RedisEndpoint, ...) error
- func GetRedisClient(url string, password string, db int) (*redis.Client, error)
- func GetRedisInfo(ctx context.Context, client redis.Cmdable, section string) (map[string]string, error)
- func PingRedis(ctx context.Context, client redis.Cmdable) error
- func ScanAllKeys(ctx context.Context, endpoint *config.RedisEndpoint, pattern string, ...) ([]string, error)
- type ClusterNodeInfo
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
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 DetectClusterMode ¶ added in v1.1.0
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
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 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
ParseClusterNodes runs CLUSTER NODES and parses the output.