redisutil

package
v1.1.64 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package redisutil provides utilities for handling Redis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*redis.Client
}

Client is a wrapper for *redis.Client providing a handy Close() function.

func DialRedis

func DialRedis(opts ...Opt) (*Client, error)

DialRedis creates a connection to Redis using values from specified config.Config, and returns Client instance.

func (*Client) Close

func (c *Client) Close()

Close closes a connection to Redis.

type Config added in v1.1.58

type Config struct {
	// Address is a remote host and port to connect to.
	Address string

	// Username is an optional property used in authorization.
	Username string

	// Password is an optional property used in authorization.
	Password string

	// DB is a database number to use (default: 0).
	DB int

	// TLSConfig setting it to non-nil value enables TLS mode.
	TLSConfig *tls.Config

	// ConnectionTimeout is a maximum time client should spend trying to connect (default: 5s).
	ConnectionTimeout time.Duration
}

Config holds a configuration for Client.

type Opt added in v1.1.58

type Opt = func(*Config)

Opt is an option to be specified to DialRedis.

func Address added in v1.1.58

func Address(address string) Opt

Address is a remote host and port to connect to.

func ConnectionTimeout added in v1.1.58

func ConnectionTimeout(connectionTimeout time.Duration) Opt

ConnectionTimeout is a maximum time client should spend trying to connect.

func DB added in v1.1.58

func DB(db int) Opt

DB is a database number to use.

func Password added in v1.1.58

func Password(password string) Opt

Password is an optional property used in authorization.

func TLSConfig added in v1.1.58

func TLSConfig(tlsConfig *tls.Config) Opt

TLSConfig setting it to non-nil value enables TLS mode.

func Username added in v1.1.58

func Username(username string) Opt

Username is an optional property used in authorization.

Jump to

Keyboard shortcuts

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