redis

package
v0.0.0-...-b08fcc5 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Nil reply returned by Redis when key does not exist.
	Nil = redis.Nil
)

Functions

func IsNil

func IsNil(err error) bool

IsNil Nil reply returned by Redis when key does not exist.

Types

type Option

type Option func(o *Options)

func SetAddr

func SetAddr(addr string) Option

host:port address. SetAddr

func SetDB

func SetDB(db int) Option

Database to be selected after connecting to the server. SetDB

func SetDialTimeout

func SetDialTimeout(dialTimeout time.Duration) Option

Dial timeout for establishing new connections. Default is 5 seconds. SetDialTimeout

func SetDialer

func SetDialer(dialer func(ctx context.Context, network, addr string) (net.Conn, error)) Option

Dialer creates new network connection and has priority over Network and Addr options. SetDialer

func SetIdleCheckFrequency

func SetIdleCheckFrequency(idleCheckFrequency time.Duration) Option

Frequency of idle checks made by idle connections reaper. Default is 1 minute. -1 disables idle connections reaper, but idle connections are still discarded by the client if IdleTimeout is set. SetIdleCheckFrequency

func SetIdleTimeout

func SetIdleTimeout(idleTimeout time.Duration) Option

Amount of time after which client closes idle connections. Should be less than server's timeout. Default is 5 minutes. -1 disables idle timeout check. SetIdleTimeout

func SetLimiter

func SetLimiter(Limiter redis.Limiter) Option

Limiter interface used to implemented circuit breaker or rate limiter. SetLimiter

func SetMaxConnAge

func SetMaxConnAge(maxConnAge time.Duration) Option

Connection age at which client retires (closes) the connection. Default is to not close aged connections. SetMaxConnAge

func SetMaxRetries

func SetMaxRetries(maxRetries int) Option

Maximum number of retries before giving up. Default is 3 retries; -1 (not 0) disables retries. SetMaxRetries

func SetMaxRetryBackoff

func SetMaxRetryBackoff(maxRetryBackoff time.Duration) Option

Maximum backoff between each retry. Default is 512 milliseconds; -1 disables backoff. SetMaxRetryBackoff

func SetMinIdleConns

func SetMinIdleConns(minIdleConns int) Option

Minimum number of idle connections which is useful when establishing new connection is slow. SetMinIdleConns

func SetMinRetryBackoff

func SetMinRetryBackoff(minRetryBackoff time.Duration) Option

Minimum backoff between each retry. Default is 8 milliseconds; -1 disables backoff. SetMinRetryBackoff

func SetNetwork

func SetNetwork(network string) Option

The network type, either tcp or unix. Default is tcp. SetNetwork

func SetOnConnect

func SetOnConnect(onConnect func(ctx context.Context, cn *redis.Conn) error) Option

Hook that is called when new connection is established. SetOnConnect

func SetPassword

func SetPassword(password string) Option

Optional password. Must match the password specified in the requirepass server configuration option (if connecting to a Redis 5.0 instance, or lower), or the User Password when connecting to a Redis 6.0 instance, or greater, that is using the Redis ACL system. SetPassword

func SetPoolSize

func SetPoolSize(PoolSize int) Option

Maximum number of socket connections. Default is 10 connections per every CPU as reported by runtime.NumCPU. SetPoolSize

func SetPoolTimeout

func SetPoolTimeout(poolTimeout time.Duration) Option

Amount of time client waits for connection if all connections are busy before returning an error. Default is ReadTimeout + 1 second. SetPoolTimeout

func SetReadOnly

func SetReadOnly(readOnly bool) Option

Enables read only queries on slave nodes. SetReadOnly

func SetReadTimeout

func SetReadTimeout(readTimeout time.Duration) Option

Timeout for socket reads. If reached, commands will fail with a timeout instead of blocking. Use value -1 for no timeout and 0 for default. Default is 3 seconds. SetReadTimeout

func SetServerName

func SetServerName(serverName string) Option

SetServerName set servername

func SetTLSConfig

func SetTLSConfig(tLSConfig *tls.Config) Option

TLS Config to use. When set TLS will be negotiated. SetTLSConfig

func SetUsername

func SetUsername(username string) Option

Use the specified Username to authenticate the current connection with one of the connections defined in the ACL list when connecting to a Redis 6.0 instance, or greater, that is using the Redis ACL system. SetUsername

func SetWriteTimeout

func SetWriteTimeout(writeTimeout time.Duration) Option

Timeout for socket writes. If reached, commands will fail with a timeout instead of blocking. Default is ReadTimeout. SetWriteTimeout

type Options

type Options struct {
	ServerName string
	redis.Options
}

type Redis

type Redis struct {
	*redis.Client
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Redis, error)

func (*Redis) Init

func (r *Redis) Init()

Jump to

Keyboard shortcuts

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