redis_db

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 7 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRedisURL

func ParseRedisURL(rawURL string, skipTLSVerify bool) (*redis.Options, error)

parseRedisURL parses a Redis URL into Redis options, handling various URL formats including Azure Redis Cache URLs with special characters in passwords.

Types

type ConnOpt

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

ConnOpt adapts a pooled go-redis client to asynq's RedisConnOpt interface without importing asynq. asynq.RedisClientOpt cannot express ConnMaxIdleTime, so clients built from it reuse connections that managed Redis/Valkey already idle-closed ("write: broken pipe").

func NewConnOpt

func NewConnOpt(rawURL string, skipTLSVerify bool, pool ...*PoolConfig) (ConnOpt, error)

NewConnOpt builds an asynq-compatible connection option whose underlying client recycles idle connections. Each call creates a dedicated client, so an asynq consumer closing its connection does not tear down another's.

func (ConnOpt) MakeRedisClient

func (o ConnOpt) MakeRedisClient() interface{}

MakeRedisClient satisfies asynq.RedisConnOpt.

type PoolConfig

type PoolConfig struct {
	PoolSize     int
	MinIdleConns int
	// ConnMaxIdleTime is how long a pooled connection may sit idle before it
	// is discarded instead of reused. Zero applies defaultConnMaxIdleTime;
	// negative disables recycling.
	ConnMaxIdleTime time.Duration
}

PoolConfig holds Redis connection pool settings.

type Redis

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

Redis struct holds the Redis client and addresses of Redis instances. It supports both single-instance Redis connections and Redis Cluster setups.

func NewRedisClient

func NewRedisClient(addresses []string, skipTLSVerify bool, pool ...*PoolConfig) (*Redis, error)

NewRedisClient creates a new Redis client connection based on the provided list of addresses. It automatically detects if the connection is for a single Redis instance or a Redis Cluster.

Parameters: - addresses []string: A list of Redis addresses. For a single Redis instance, provide one address. - skipTLSVerify bool: Whether to skip TLS certificate verification

Returns: - *Redis: A new Redis client wrapper. - error: An error if the provided address is invalid or connection setup fails.

func (*Redis) Client

func (r *Redis) Client() redis.UniversalClient

Client returns the Redis universal client. It can be used directly for Redis operations like Get, Set, or Publish.

Returns: - redis.UniversalClient: The universal Redis client, which supports both standalone and clustered Redis instances.

func (*Redis) MakeRedisClient

func (r *Redis) MakeRedisClient() interface{}

MakeRedisClient returns the Redis client interface, allowing compatibility with other packages or tools.

Returns: - interface{}: The Redis client interface.

Jump to

Keyboard shortcuts

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