myredis

package
v0.0.0-...-faf29f7 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MyRedis

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

MyRedis redis配置项

func DefaultConf

func DefaultConf() *MyRedis

DefaultConf ...

func InitDefaultRedis

func InitDefaultRedis(ops ...Option) *MyRedis

InitDefaultRedis 初始化(必须要优先调用一次)

func InitRedis

func InitRedis(ops ...Option) *MyRedis

InitRedis 初始化(必须要优先调用一次)

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option 功能选项

func WithAddr

func WithAddr(addr ...string) Option

WithAddr 密码

func WithClientName

func WithClientName(name string) Option

WithClientName 指定Redis服务器连接使用的客户端名称

func WithDB

func WithDB(db int) Option

WithDB 数据库地址(index)

func WithGroupName

func WithGroupName(groupName string) Option

WithGroupName 分组名

func WithLog

func WithLog(isLog bool) Option

func WithPool

func WithPool(maxIdle, maxActive int) Option

WithPool 连接池配置

func WithPwd

func WithPwd(pwd string) Option

WithPwd 密码

func WithReadTimeout

func WithReadTimeout(timeout time.Duration) Option

WithReadTimeout 设置读过期时间

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout 设置过期时间

func WithWriteTimeout

func WithWriteTimeout(timeout time.Duration) Option

WithWriteTimeout 设置写过期时间

type RedisDial

type RedisDial interface {
	Destory()                                                                       // 析构
	GetRedisClient() redis.Conn                                                     // 获取一个原始的redis连接
	Ping() bool                                                                     // 判断是否能ping通
	Add(key interface{}, value interface{}, lifeSpan time.Duration) error           // 添加一个元素
	Value(key interface{}, value interface{}) error                                 // 获取一个value
	IsExist(key interface{}) bool                                                   // 判断是否存在
	Delete(key interface{}) error                                                   // 删除一个
	Clear() error                                                                   // 清空
	GetKeyS(key interface{}) ([]string, error)                                      // 查询所有key
	Close() (err error)                                                             // 关闭连接
	Do(commandName string, args ...interface{}) (reply interface{}, err error)      // 一次操作
	TryLock(key interface{}, value interface{}, lifeSpan time.Duration) (err error) //  试着加锁
	Unlock(key interface{}) (err error)                                             // 解锁
	Refresh(key interface{}, lifeSpan time.Duration) error                          // 更新时间
}

RedisDial 操作

func NewRedis

func NewRedis(con *MyRedis) (dial RedisDial, err error)

NewRedis 初始化一个(InitDefaultRedis(需要优先调用)) groupName:分组名

Jump to

Keyboard shortcuts

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