redis

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 6 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 NewRedisClient

func NewRedisClient(conf Conf) *Client

NewRedisClient 初始化Redis连接池

func (*Client) Destroy

func (cli *Client) Destroy()

Destroy 销毁数据库客户端

func (*Client) Lock

func (cli *Client) Lock(key string, expiration time.Duration) bool

Lock 分布式锁加锁

func (*Client) Unlock

func (cli *Client) Unlock(key string) bool

Unlock 分布式锁解锁

func (*Client) WrapKey

func (cli *Client) WrapKey(subKey string) string

WrapKey 使用配置的命名空间包装Key,返回一个包装过的key

type Conf

type Conf struct {
	DB          int      `yaml:"db"`
	Namespace   string   `yaml:"namespace"`
	Type        RdbType  `yaml:"type"`
	MasterName  string   `yaml:"masterName"`
	Addrs       []string `yaml:"addrs"`
	Password    string   `yaml:"password"`
	PoolSize    int      `yaml:"poolSize"`
	MaxIdleConn int      `yaml:"maxIdleConn"`
	Timeout     int      `yaml:"timeout"`
}

Conf Redis相关配置

type RdbType

type RdbType string

RdbType Redis类型

const (
	// RdbCluster Redis集群
	RdbCluster RdbType = "cluster"
	// RdbSentinel Redis哨兵
	RdbSentinel RdbType = "sentinel"
)

Jump to

Keyboard shortcuts

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