redis

package
v0.0.0-...-ac9cef7 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScriptHPop = `
		local v = redis.call("HGET", KEYS[1], ARGV[1])
		redis.call("HDEL", KEYS[1], ARGV[1])
		return v
	`
)

Variables

View Source
var (
	MaxFail      = 6
	FailureRetry = 3

	ServerEmptyErr        = errors.New("redis: servers is empty")
	ServerNonAvailableErr = errors.New("redis: server non available ")

	WrongAnswer = errors.New("redis: get wrong answer")
	EmptyAnswer = errors.New("redis: get empty answer")
)

Functions

func CheckLocked

func CheckLocked(pool *Pool, key string) bool

func DeQueue

func DeQueue(pool *Pool, queueName string) (key string, data []byte)

func EnQueue

func EnQueue(pool *Pool, queueName, key string, data []byte) error

func EnQueueReliably

func EnQueueReliably(pool *Pool, queue string, key string, data []byte) (err error)

func Lock

func Lock(globalPool *Pool, key string, maxRetry, expiredSecond int) error

func LockByExpireTime

func LockByExpireTime(globalPool *Pool, key string, timeout time.Duration, expired int) error

LockByExpireTime 获取锁,可以自定义重试时长、锁超时时间。

func UnLock

func UnLock(globalPool *Pool, key string) error

Types

type Pool

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

func NewRedisPool

func NewRedisPool(s []Server) (*Pool, error)

func (*Pool) AddToSet

func (p *Pool) AddToSet(key string, val []string) error

func (*Pool) Close

func (p *Pool) Close() error

func (*Pool) Del

func (p *Pool) Del(key string) error

func (*Pool) Do

func (p *Pool) Do(cmdStr string, args ...any) (reply any, err error)

func (*Pool) Expire

func (p *Pool) Expire(key string, t int) error

func (*Pool) FailOver

func (p *Pool) FailOver()

func (*Pool) Get

func (p *Pool) Get(key string) (any, error)

func (*Pool) GetHashValues

func (p *Pool) GetHashValues(hTable string, keys []string) ([]string, error)

func (*Pool) GetSet

func (p *Pool) GetSet(key, value string) (any, error)

func (*Pool) GetTime

func (p *Pool) GetTime() (second, microSecond int64, err error)

func (*Pool) GetsFromSet

func (p *Pool) GetsFromSet(key string) ([]string, error)

func (*Pool) HGet

func (p *Pool) HGet(hTable, key string) (any, error)

func (*Pool) HKeys

func (p *Pool) HKeys(hTable string) ([]string, error)

func (*Pool) HLen

func (p *Pool) HLen(hTable string) (any, error)

func (*Pool) HPop

func (p *Pool) HPop(hTable, key string) (any, error)

func (*Pool) HSet

func (p *Pool) HSet(hTable, key, val string) (int64, error)

func (*Pool) HSetNX

func (p *Pool) HSetNX(hTable, key, val string) (int64, error)

func (*Pool) Incr

func (p *Pool) Incr(key string) (int64, error)

func (*Pool) LLen

func (p *Pool) LLen(key string) (int64, error)

func (*Pool) LPop

func (p *Pool) LPop(key string) (any, error)

func (*Pool) LPush

func (p *Pool) LPush(args ...any) error

func (*Pool) LRange

func (p *Pool) LRange(key string, start, end int) (any, error)

func (*Pool) Multi

func (p *Pool) Multi(cmds []map[string]string) (any, error)

func (*Pool) MultiVariable

func (p *Pool) MultiVariable(cmds []map[string][]interface{}) (any, error)

func (*Pool) RPop

func (p *Pool) RPop(key string) (any, error)

func (*Pool) RPush

func (p *Pool) RPush(args ...any) error

func (*Pool) Recover

func (p *Pool) Recover()

func (*Pool) RmFromSet

func (p *Pool) RmFromSet(key, val string) error

func (*Pool) Set

func (p *Pool) Set(key, value string) error

func (*Pool) SetEx

func (p *Pool) SetEx(key, value string, seconds int) error

func (*Pool) SetNx

func (p *Pool) SetNx(key, value string) (int64, error)

func (*Pool) TTL

func (p *Pool) TTL(key string) (int64, error)

type Server

type Server struct {
	Host string
	Port string
	Auth string
	DB   string
}

Jump to

Keyboard shortcuts

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