redis

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAddr = "127.0.0.1:6379"
View Source
var DefaultClusterAddrs = "127.0.0.1:7001;127.0.0.1:7002;127.0.0.1:7003;127.0.0.1:7004;127.0.0.1:7005;127.0.0.1:7006"
View Source
var NotReadyErr = errors.New("RedisNotReady")
View Source
var RDB = &Redis{}

Functions

func AddMembersToSet

func AddMembersToSet(key string, values ...interface{}) (interface{}, error)

func Del

func Del(key string) error

func DelMembersInSet

func DelMembersInSet(key string, values ...interface{}) error

func Do

func Do(cmds ...interface{}) (interface{}, error)

func Get

func Get(key string) *redis.StringCmd

func GetAllMembersFromSet

func GetAllMembersFromSet(key string) (interface{}, error)

func GetCache

func GetCache(key string, v Encoder) error

func GetCacheOne added in v0.4.6

func GetCacheOne(key, subKey string) (string, error)

func GetInt

func GetInt(key string) (int, error)

func GetInt64

func GetInt64(key string) (int64, error)

func GetString

func GetString(key string) (string, error)

func GetUint64

func GetUint64(key string) (uint64, error)

func Incr

func Incr(key string) (int64, error)

func Initialize

func Initialize(ctx contextx.Context, opfs ...func(rdb RdbConfig))

func LockExec

func LockExec(key string, f func(key string)) error

func MembersCountOfSet

func MembersCountOfSet(key string) (int64, error)

func Publish

func Publish(channel string, message interface{}) error

func Set

func Set(key string, value interface{}, expiration time.Duration) error

func SetCache

func SetCache(key string, v Encoder) error

func SetInt

func SetInt(key string, value int) error

func SetString

func SetString(key, value string) error

func Subscribe

func Subscribe(f func(channel, msg string), channel ...string) error

Types

type Encoder

type Encoder interface {
	Marshal() (map[string]string, error)
	Unmarshal(value map[string]string) error
}

type RdbConfig

type RdbConfig interface {
	SetAddrs(addrs string)
	SetUsername(username string)
	SetPassword(password string)
	SetDB(db int)
	SetWaitTimeout(waitTime time.Duration)
	SetPingTime(pingTime time.Duration)
}

type Redis

type Redis struct {
	Addrs       string // 连接地址
	Username    string // 用户名
	Password    string // 密码
	DB          int    // 数据库名
	WaitTimeout time.Duration
	PingTime    time.Duration
	// contains filtered or unexported fields
}

func (*Redis) Close

func (rd *Redis) Close() error

func (*Redis) Del

func (rd *Redis) Del(ctx context.Context, keys ...string) *redis.IntCmd

func (*Redis) Do

func (rd *Redis) Do(ctx context.Context, args ...interface{}) *redis.Cmd

func (*Redis) Get

func (rd *Redis) Get(ctx context.Context, key string) *redis.StringCmd

func (*Redis) HGet added in v0.4.6

func (rd *Redis) HGet(ctx context.Context, key, subKey string) *redis.StringCmd

func (*Redis) HGetAll

func (rd *Redis) HGetAll(ctx context.Context, key string) *redis.StringStringMapCmd

func (*Redis) HMSet

func (rd *Redis) HMSet(ctx context.Context, key string, value ...interface{}) *redis.BoolCmd

func (*Redis) Incr

func (rd *Redis) Incr(ctx context.Context, key string) *redis.IntCmd

func (*Redis) Ping

func (rd *Redis) Ping(ctx context.Context) *redis.StatusCmd

func (*Redis) Publish

func (rd *Redis) Publish(ctx context.Context, channel string, message interface{}) *redis.IntCmd

func (*Redis) Set

func (rd *Redis) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd

func (*Redis) SetAddrs

func (rd *Redis) SetAddrs(addrs string)

func (*Redis) SetDB

func (rd *Redis) SetDB(db int)

func (*Redis) SetNX

func (rd *Redis) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.BoolCmd

func (*Redis) SetPassword

func (rd *Redis) SetPassword(password string)

func (*Redis) SetPingTime

func (rd *Redis) SetPingTime(pingTime time.Duration)

func (*Redis) SetUsername

func (rd *Redis) SetUsername(username string)

func (*Redis) SetWaitTimeout

func (rd *Redis) SetWaitTimeout(waitTime time.Duration)

func (*Redis) Subscribe

func (rd *Redis) Subscribe(ctx context.Context, channels ...string) (*redis.PubSub, error)

Jump to

Keyboard shortcuts

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