redis

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnExhausted = errors.New("redis: connection exhausted, please retry")
	ErrTimeout       = errors.New("redis: i/o timeout, please retry")
)

Functions

func Bool

func Bool(reply interface{}, err error) (interface{}, error)

func ByteSlices

func ByteSlices(reply interface{}, err error) (interface{}, error)

func Bytes

func Bytes(reply interface{}, err error) (interface{}, error)

func Float64

func Float64(reply interface{}, err error) (interface{}, error)

func Int

func Int(reply interface{}, err error) (interface{}, error)

func Int64

func Int64(reply interface{}, err error) (interface{}, error)

func Int64Map

func Int64Map(reply interface{}, err error) (interface{}, error)

func IntMap

func IntMap(reply interface{}, err error) (interface{}, error)

func Ints

func Ints(reply interface{}, err error) (interface{}, error)

func String

func String(reply interface{}, err error) (interface{}, error)

func StringMap

func StringMap(reply interface{}, err error) (interface{}, error)

func Strings

func Strings(reply interface{}, err error) (interface{}, error)

func Uint64

func Uint64(reply interface{}, err error) (uint64, error)

Types

type Config

type Config struct {
	Name           string `json:"name"`
	Addr           string `json:"addr"`
	Password       string `json:"password"`
	MaxIdle        int    `json:"max_idle"`
	MaxActive      int    `json:"max_active"`
	IdleTimeout    int    `json:"idle_timeout"`
	ConnectTimeout int    `json:"connect_timeout"`
	ReadTimeout    int    `json:"read_timeout"`
	WriteTimeout   int    `json:"write_timeout"`
	Database       int    `json:"database"`
	SlowTime       int    `json:"slow_time"`
	Retry          int    `json:"retry"`
}

type Manager

type Manager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewManager

func NewManager(c []Config) (*Manager, error)

func (*Manager) Add

func (m *Manager) Add(name string, r *Redis)

func (*Manager) Get

func (m *Manager) Get(name string) *Redis

type Pipeline

type Pipeline struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

func (*Pipeline) Close

func (p *Pipeline) Close() error

func (*Pipeline) Flush

func (p *Pipeline) Flush() error

func (*Pipeline) Receive

func (p *Pipeline) Receive() (reply interface{}, err error)

func (*Pipeline) Send

func (p *Pipeline) Send(cmd string, args ...interface{}) error

type Redis

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

func NewRedis

func NewRedis(cfg *Config) (store *Redis, err error)

func (*Redis) Del

func (r *Redis) Del(args ...interface{}) (count int, err error)

func (*Redis) Do

func (r *Redis) Do(cmd string, args ...interface{}) (reply interface{}, err error)

func (*Redis) DoCtx

func (r *Redis) DoCtx(ctx context.Context, cmd string, args ...interface{}) (reply interface{}, err error)

func (*Redis) Exists

func (r *Redis) Exists(key string) (res bool, err error)

func (*Redis) Expire

func (r *Redis) Expire(key string, expire time.Duration) error

func (*Redis) Get

func (r *Redis) Get(key string) (ret []byte, err error)

func (*Redis) GetInt

func (r *Redis) GetInt(key string) (ret int, err error)

func (*Redis) HDel

func (r *Redis) HDel(key interface{}, fields ...interface{}) (res int, err error)

* hash

func (*Redis) HGet

func (r *Redis) HGet(key, field string) (res string, err error)

func (*Redis) HGetAll

func (r *Redis) HGetAll(key string) (res map[string]string, err error)

func (*Redis) HGetInt

func (r *Redis) HGetInt(key, field string) (res int, err error)

func (*Redis) HKeys

func (r *Redis) HKeys(key string) (res []string, err error)

func (*Redis) HMGet

func (r *Redis) HMGet(key string, fields ...interface{}) (res []string, err error)

func (*Redis) HMSet

func (r *Redis) HMSet(key string, fields ...interface{}) (res string, err error)

func (*Redis) HSet

func (r *Redis) HSet(key, fieldk string, fieldv interface{}) (res int, err error)

func (*Redis) Incrby

func (r *Redis) Incrby(key string, incr int) (res int64, err error)

func (*Redis) LLen

func (r *Redis) LLen(key string) (res int64, err error)

func (*Redis) LPush

func (r *Redis) LPush(name string, fields ...interface{}) error

func (*Redis) MGet

func (r *Redis) MGet(keys ...interface{}) (ret [][]byte, err error)

func (*Redis) MSet

func (r *Redis) MSet(keys ...interface{}) (ret string, err error)

func (*Redis) NewPipelining

func (r *Redis) NewPipelining() (*Pipeline, error)

func (*Redis) RPop

func (r *Redis) RPop(key string) (res string, err error)

func (*Redis) Receive

func (r *Redis) Receive(name string, closech chan struct{}, bufferSize int) chan []byte

func (*Redis) SAdd

func (r *Redis) SAdd(key string, members ...interface{}) (res int, err error)

* set

func (*Redis) SIsMember

func (r *Redis) SIsMember(key string, member string) (res bool, err error)

func (*Redis) SMembers

func (r *Redis) SMembers(key string) (res []string, err error)

func (*Redis) SRem

func (r *Redis) SRem(key string, members ...interface{}) (res int, err error)

func (*Redis) Send

func (r *Redis) Send(name string, fields ...interface{}) error

func (*Redis) Set

func (r *Redis) Set(key, value interface{}) (ret bool, err error)

func (*Redis) SetExSecond

func (r *Redis) SetExSecond(key, value interface{}, dur int) (ret string, err error)

func (*Redis) Subscribe

func (r *Redis) Subscribe(ctx context.Context, key string, maxSize int) (chan []byte, error)

func (*Redis) ZAdd

func (r *Redis) ZAdd(key string, args ...interface{}) (res int, err error)

ZSET

func (*Redis) ZCard

func (r *Redis) ZCard(key string) (res int, err error)

func (*Redis) ZCount

func (r *Redis) ZCount(key string, min, max int) (res int, err error)

func (*Redis) ZIncrby

func (r *Redis) ZIncrby(key string, incr int, member string) (res int, err error)

func (*Redis) ZRange

func (r *Redis) ZRange(key string, args ...interface{}) (res []string, err error)

func (*Redis) ZRangeInt

func (r *Redis) ZRangeInt(key string, start, stop int) (res []int, err error)

func (*Redis) ZRangeWithScore

func (r *Redis) ZRangeWithScore(key string, start, stop int) (res []string, err error)

func (*Redis) ZRank

func (r *Redis) ZRank(key string, member string) (res int, err error)

* If the member not in the zset or key not exits, ZRank will return ErrNil

func (*Redis) ZRem

func (r *Redis) ZRem(key string, members ...interface{}) (res int, err error)

* If the members not in the zset or key not exits, ZRem will return ErrNil

func (*Redis) ZRemrangebyrank

func (r *Redis) ZRemrangebyrank(key string, members ...interface{}) (res int, err error)

func (*Redis) ZScore

func (r *Redis) ZScore(key, member string) (res float64, err error)

* If the member not in the zset or key not exits, ZScore will return ErrNil

func (*Redis) Zrevrange

func (r *Redis) Zrevrange(key string, args ...interface{}) (res []string, err error)

func (*Redis) Zrevrangebyscore

func (r *Redis) Zrevrangebyscore(key string, args ...interface{}) (res []string, err error)

func (*Redis) ZrevrangebyscoreInt

func (r *Redis) ZrevrangebyscoreInt(key string, args ...interface{}) (res []int, err error)

Jump to

Keyboard shortcuts

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