tinyredis

package
v1.0.9 Latest Latest
Warning

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

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

Documentation

Overview

Package tinyredis 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 and returns Client instance.

func (*Client) Close

func (c *Client) Close()

Close closes a connection to Redis.

type Config

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

type Opt = func(*Config)

Opt is an option to be specified to DialRedis.

func Address

func Address(address string) Opt

Address is a remote host and port to connect to.

func ConnectionTimeout

func ConnectionTimeout(connectionTimeout time.Duration) Opt

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

func DB

func DB(db int) Opt

DB is a database number to use.

func Password

func Password(password string) Opt

Password is an optional property used in authorization.

func TLSConfig

func TLSConfig(tlsConfig *tls.Config) Opt

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

func Username

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