redis

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Network  string `env:"REDIS_NETWORK,default=tcp"`
	Addr     string `env:"REDIS_ADDRESS,default=localhost:6379"`
	Username string `env:"REDIS_USERNAME,default="`
	Password string `env:"REDIS_PASSWORD,default="`

	DB int `env:"REDIS_DB,default="`

	MaxRetries      int           `env:"REDIS_MAX_RETRIES,default=3"`
	MinRetryBackoff time.Duration `env:"REDIS_MIN_RETRY_BACKOFF,default=8ms"`
	MaxRetryBackoff time.Duration `env:"REDIS_MAX_RETRY_BACKOFF,default=512ms"`

	DialTimeout  time.Duration `env:"REDIS_DIAL_TIMEOUT,default=5s"`
	ReadTimeout  time.Duration `env:"REDIS_READ_TIMEOUT,default=3s"`
	WriteTimeout time.Duration `env:"REDIS_WRITE_TIMEOUT,default="`

	PoolSize           int           `env:"REDIS_POOL_SIZE,default=10"`
	MinIdleConns       int           `env:"REDIS_MIN_IDLE_CONNS,default="`
	MaxConnAge         time.Duration `env:"REDIS_MAX_CONN_AGE,default="`
	PoolTimeout        time.Duration `env:"REDIS_POOL_TIMEOUT,default="`
	IdleTimeout        time.Duration `env:"REDIS_IDLE_TIMEOUT,default="`
	IdleCheckFrequency time.Duration `env:"REDIS_IDLE_CHEKC_FREQUENCY,default=60s"`
}

Config defines the redis config

func NewConfig

func NewConfig() *Config

NewConfig returns the parsed config for zap from env

type Redis

type Redis struct {
	*Config
	Client *goredis.Client
}

Redis hold the redis config and redis client

func NewRedisClient

func NewRedisClient(config *Config) *Redis

NewRedisClient creates a new redis client using the env config

Jump to

Keyboard shortcuts

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