redis

package
v0.0.0-...-4e4c4f6 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(key string) (string, error)

func SAdd

func SAdd(key string, members []interface{}) (int, error)

向集合添加一个或多个成员

func SCard

func SCard(key string) (int, error)

获取集合的成员数量

func SInter

func SInter(keys []interface{}) ([]string, error)

返回给定所有集合的交集

func SIsMember

func SIsMember(key, member string) (int, error)

判断元素是否是集合的成员

func SMembers

func SMembers(key string) ([]string, error)

返回集合中的所有成员

func SRem

func SRem(key string, members []interface{}) (int, error)

移除集合中一个或多个成员

func Set

func Set(key, value string) (string, error)

字符串命令

func SetEx

func SetEx(key, value string, seconds int) (string, error)

Types

type BwRedisClient

type BwRedisClient struct {
	*redis.Pool
}

func NewRedis

func NewRedis(config *Config) (*BwRedisClient, error)

func (*BwRedisClient) ActiveCount

func (r *BwRedisClient) ActiveCount() int

func (*BwRedisClient) Bool

func (r *BwRedisClient) Bool(cmd string, args ...interface{}) (bool, error)

返回 bool

func (*BwRedisClient) ByteSlices

func (r *BwRedisClient) ByteSlices(cmd string, args ...interface{}) ([][]byte, error)

返回 [][]byte

func (*BwRedisClient) Bytes

func (r *BwRedisClient) Bytes(cmd string, args ...interface{}) ([]byte, error)

返回 bytes

func (*BwRedisClient) Float64

func (r *BwRedisClient) Float64(cmd string, args ...interface{}) (float64, error)

返回 float64

func (*BwRedisClient) Float64s

func (r *BwRedisClient) Float64s(cmd string, args ...interface{}) ([]float64, error)

返回 []float64

func (*BwRedisClient) IdleCount

func (r *BwRedisClient) IdleCount() int

func (*BwRedisClient) Int

func (r *BwRedisClient) Int(cmd string, args ...interface{}) (int, error)

返回 int

func (*BwRedisClient) Int64

func (r *BwRedisClient) Int64(cmd string, args ...interface{}) (int64, error)

返回 int64

func (*BwRedisClient) Int64Map

func (r *BwRedisClient) Int64Map(cmd string, args ...interface{}) (map[string]int64, error)

返回 map[string]int64

func (*BwRedisClient) Int64s

func (r *BwRedisClient) Int64s(cmd string, args ...interface{}) ([]int64, error)

返回 []int64

func (*BwRedisClient) IntMap

func (r *BwRedisClient) IntMap(cmd string, args ...interface{}) (map[string]int, error)

返回 map[string]int

func (*BwRedisClient) Ints

func (r *BwRedisClient) Ints(cmd string, args ...interface{}) ([]int, error)

返回 []int

func (*BwRedisClient) Positions

func (r *BwRedisClient) Positions(cmd string, args ...interface{}) ([]*[2]float64, error)

返回 positions

func (*BwRedisClient) Status

func (r *BwRedisClient) Status() *NvRedisStatus

func (*BwRedisClient) String

func (r *BwRedisClient) String(cmd string, args ...interface{}) (string, error)

返回 string

func (*BwRedisClient) StringMap

func (r *BwRedisClient) StringMap(cmd string, args ...interface{}) (map[string]string, error)

返回 map[string]string

func (*BwRedisClient) Strings

func (r *BwRedisClient) Strings(cmd string, args ...interface{}) ([]string, error)

返回 []string

func (*BwRedisClient) Uint64

func (r *BwRedisClient) Uint64(cmd string, args ...interface{}) (uint64, error)

返回 uint64

func (*BwRedisClient) Values

func (r *BwRedisClient) Values(cmd string, args ...interface{}) ([]interface{}, error)

返回 []interface{}

type Config

type Config struct {
	Address  string
	Auth     string
	Database int

	MaxIdle        int
	MaxActive      int
	IdleTimeout    time.Duration
	ConnectTimeout time.Duration
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
}

type DistributeLock

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

func NewDistributeLock

func NewDistributeLock(opts ...DistributeLockOpt) *DistributeLock

初始化

func (*DistributeLock) Lock

func (d *DistributeLock) Lock(key, value string) (bool, error)

加锁

func (*DistributeLock) UnLock

func (d *DistributeLock) UnLock(key, value string) (int, error)

解锁 TODO 验证加锁和解锁是同一个

type DistributeLockOpt

type DistributeLockOpt func(*DistributeLock)

func SetExpireSecond

func SetExpireSecond(expire int) DistributeLockOpt

设置过期时间秒数

type NvRedisShortClient

type NvRedisShortClient struct {
	redis.Conn
}

短连接

func NewRedisShort

func NewRedisShort(address string) (*NvRedisShortClient, error)

func (*NvRedisShortClient) CloseConn

func (r *NvRedisShortClient) CloseConn() error

func (*NvRedisShortClient) ReplyBool

func (r *NvRedisShortClient) ReplyBool(cmd string, args ...interface{}) (bool, error)

func (*NvRedisShortClient) ReplyBytes

func (r *NvRedisShortClient) ReplyBytes(cmd string, args ...interface{}) ([]byte, error)

func (*NvRedisShortClient) ReplyFloat64

func (r *NvRedisShortClient) ReplyFloat64(cmd string, args ...interface{}) (float64, error)

func (*NvRedisShortClient) ReplyInt

func (r *NvRedisShortClient) ReplyInt(cmd string, args ...interface{}) (int, error)

func (*NvRedisShortClient) ReplyInt64

func (r *NvRedisShortClient) ReplyInt64(cmd string, args ...interface{}) (int64, error)

func (*NvRedisShortClient) ReplyString

func (r *NvRedisShortClient) ReplyString(cmd string, args ...interface{}) (string, error)

func (*NvRedisShortClient) ReplyUint64

func (r *NvRedisShortClient) ReplyUint64(cmd string, args ...interface{}) (uint64, error)

type NvRedisStatus

type NvRedisStatus struct {
	// 连接池状态统计
	PoolActiveCount int
	PoolIdleCount   int
}

Jump to

Keyboard shortcuts

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