redis

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClusterType means redis cluster.
	ClusterType = "cluster"
	// NodeType means redis node.
	NodeType = "node"
	// Nil is an alias of redis.Nil.
	Nil = stdRedis.Nil
)

Variables

View Source
var (
	ErrEmptyHost = errors.New("empty redis host")
)

Functions

This section is empty.

Types

type Option

type Option func(r *Redis)

Option defines the method to customize a Redis.

func Cluster

func Cluster() Option

Cluster customizes the given Redis as a cluster.

func WithPass

func WithPass(pass string) Option

func WithTLS

func WithTLS() Option

WithTLS customizes the given Redis with TLS enabled.

type Redis

type Redis struct {
	Addr string
	Type string
	Pass string
	// contains filtered or unexported fields
}

Redis defines a redis node/cluster. It is thread-safe.

func New

func New(addr string, opts ...Option) *Redis

func (*Redis) Decr

func (s *Redis) Decr(key string) (int64, error)

func (*Redis) DecrCtx

func (s *Redis) DecrCtx(ctx context.Context, key string) (value int64, err error)

type RedisConf

type RedisConf struct {
	Host string
	Type string `json:",default=node,options=node|cluster"`
	Pass string `json:"optional"`
}

A RedisConf is a redis config.

func (RedisConf) Validate

func (rc RedisConf) Validate() error

Validate validates the RedisConf.

type RedisKeyConf

type RedisKeyConf struct {
	RedisConf
	Key string `json:",optional"`
}

A RedisKeyConf is a redis config with key.

type RedisNode

type RedisNode interface {
	stdRedis.Cmdable
}

Jump to

Keyboard shortcuts

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