redis

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(opt Option) (Client, error)

func (Client) Close

func (c Client) Close() error

Close closes the database connection.

func (Client) Delete

func (c Client) Delete(ctx context.Context, key string) error

Delete deletes the value for the given key.

func (Client) Get

func (c Client) Get(ctx context.Context, key string, value models.Model) error

func (Client) List

func (c Client) List(ctx context.Context, prefix string) (keys []string, err error)

List lists all the keys from the database.

func (Client) Set

func (c Client) Set(ctx context.Context, key string, value models.Model) error

type Option

type Option struct {
	// DBRedisAddress is the address of the redis database
	Address string `default:"localhost:6379"`

	// Password is the password of the redis database
	Password string

	// Username is the username of the redis database
	Username string

	// DB is the database number of the redis database
	DB int `default:"0"`

	// MaxRetries is the maximum number of retries before giving up
	MaxRetries int `default:"3"`

	// DialTimeout is the maximum number of retries before giving up
	DialTimeout int `default:"5"`

	// ReadTimeout is the maximum number of retries before giving up
	ReadTimeout int `default:"3"`

	// WriteTimeout is the maximum number of retries before giving up
	WriteTimeout int `default:"3"`

	CertFile string
	KeyFile  string
	CAFile   string
}

Jump to

Keyboard shortcuts

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