redis

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package redis tool

Package redis

Package redis

Package redis

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimpleDel

func SimpleDel()

func SimpleDelAll

func SimpleDelAll()

func SimpleExists

func SimpleExists()

func SimpleGet

func SimpleGet()

func SimpleGetLock

func SimpleGetLock()

func SimpleNewRedis

func SimpleNewRedis()

func SimpleQuotaLimit

func SimpleQuotaLimit()

func SimpleReadStreamsAndAck

func SimpleReadStreamsAndAck()

func SimpleReadStreamsAndAck2

func SimpleReadStreamsAndAck2()

func SimpleRegister

func SimpleRegister()

func SimpleSet

func SimpleSet()

func SimpleSetEx

func SimpleSetEx()

func SimpleStreamAdd

func SimpleStreamAdd()
func SimpleUnlink()

func SimpleWithLock

func SimpleWithLock()

func SimpleZAdd

func SimpleZAdd()

func SimpleZRangeByScore

func SimpleZRangeByScore()

func SimpleZRem

func SimpleZRem()

Types

type Options

type Options struct {
	v8.Options
}

func DefaultOptions

func DefaultOptions() Options

func NewOptions

func NewOptions() *Options

type Redis

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

func FromV8 added in v1.3.1

func FromV8(cli *v8.Client) *Redis

func NewRedis

func NewRedis(opt *Options) *Redis

func NewRedisWithCtx

func NewRedisWithCtx(ctx context.Context, opt *Options) *Redis

func (*Redis) BitCount

func (r *Redis) BitCount(ctx context.Context, key string, bitStart, bitEnd int64) (int64, error)

func (*Redis) BitCountAll

func (r *Redis) BitCountAll(ctx context.Context, key string) (int64, error)

func (*Redis) BitField

func (r *Redis) BitField(ctx context.Context, key string, args ...interface{}) ([]int64, error)

func (*Redis) BitOpAnd

func (r *Redis) BitOpAnd(ctx context.Context, destKey string, keys ...string) (int64, error)

func (*Redis) BitOpNot

func (r *Redis) BitOpNot(ctx context.Context, destKey string, key string) (int64, error)

func (*Redis) BitOpOr

func (r *Redis) BitOpOr(ctx context.Context, destKey string, keys ...string) (int64, error)

func (*Redis) BitOpXor

func (r *Redis) BitOpXor(ctx context.Context, destKey string, keys ...string) (int64, error)

func (*Redis) BitPos

func (r *Redis) BitPos(ctx context.Context, key string, bit int64, pos ...int64) (int64, error)

func (*Redis) Close

func (r *Redis) Close() error

func (*Redis) Del

func (r *Redis) Del(ctx context.Context, key ...string) (int64, error)

func (*Redis) Exists

func (r *Redis) Exists(ctx context.Context, key ...string) (int64, error)

func (*Redis) FreeLock

func (r *Redis) FreeLock(key string) error

FreeLock 释放指定的redis锁

func (*Redis) Get

func (r *Redis) Get(ctx context.Context, key string) (string, error)

func (*Redis) GetBit

func (r *Redis) GetBit(ctx context.Context, key string, offset int64) (int64, error)

func (*Redis) GetLock

func (r *Redis) GetLock(key string, lockVal *string, exp int) error

GetLock 获取redis锁,成功返回nil,否则返回对应error

func (*Redis) HScan

func (r *Redis) HScan(ctx context.Context, key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error)

func (*Redis) PTTL

func (r *Redis) PTTL(ctx context.Context, key string) (int64, error)

func (*Redis) Ping

func (r *Redis) Ping(ctx context.Context) string

func (*Redis) QuotaLimit

func (r *Redis) QuotaLimit(limitKay string, maxCount int, exp int, addCount int, addLock bool) bool

QuotaLimit 资源量限制,被限制返回true,否则返回false

func (*Redis) Raw

func (r *Redis) Raw() (*v8.Client, context.Context)

func (*Redis) RawCtx

func (r *Redis) RawCtx() context.Context

func (*Redis) RawRedis

func (r *Redis) RawRedis() *v8.Client

func (*Redis) Register

func (r *Redis) Register(key string, val string, exp int) bool

Register 注册HA 主服务标识,注册成功返回true,否则返回false

func (*Redis) SAdd

func (r *Redis) SAdd(ctx context.Context, key string, members ...interface{}) (int64, error)

func (*Redis) SCard

func (r *Redis) SCard(ctx context.Context, key string) (int64, error)

func (*Redis) SDiff

func (r *Redis) SDiff(ctx context.Context, keys ...string) ([]string, error)

func (*Redis) SDiffStore

func (r *Redis) SDiffStore(ctx context.Context, destination string, keys ...string) (int64, error)

func (*Redis) SInter

func (r *Redis) SInter(ctx context.Context, keys ...string) ([]string, error)

func (*Redis) SInterStore

func (r *Redis) SInterStore(ctx context.Context, destination string, keys ...string) (int64, error)

func (*Redis) SIsMember

func (r *Redis) SIsMember(ctx context.Context, key string, member interface{}) (bool, error)

func (*Redis) SMIsMember

func (r *Redis) SMIsMember(ctx context.Context, key string, members ...interface{}) ([]bool, error)

func (*Redis) SMembers

func (r *Redis) SMembers(ctx context.Context, key string) ([]string, error)

func (*Redis) SMembersMap

func (r *Redis) SMembersMap(ctx context.Context, key string) (map[string]struct{}, error)

func (*Redis) SMove

func (r *Redis) SMove(ctx context.Context, source, destination string, member interface{}) (bool, error)

func (*Redis) SPop

func (r *Redis) SPop(ctx context.Context, key string) (string, error)

func (*Redis) SPopN

func (r *Redis) SPopN(ctx context.Context, key string, count int64) ([]string, error)

func (*Redis) SRandMember

func (r *Redis) SRandMember(ctx context.Context, key string) (string, error)

func (*Redis) SRandMemberN

func (r *Redis) SRandMemberN(ctx context.Context, key string, count int64) ([]string, error)

func (*Redis) SRem

func (r *Redis) SRem(ctx context.Context, key string, members ...interface{}) (int64, error)

func (*Redis) SScan

func (r *Redis) SScan(ctx context.Context, key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error)

func (*Redis) SUnion

func (r *Redis) SUnion(ctx context.Context, keys ...string) ([]string, error)

func (*Redis) SUnionStore

func (r *Redis) SUnionStore(ctx context.Context, destination string, keys ...string) (int64, error)

func (*Redis) Scan

func (r *Redis) Scan(ctx context.Context, cursor uint64, match string, count int64) (keys []string, cur uint64, err error)

func (*Redis) ScanType

func (r *Redis) ScanType(ctx context.Context, cursor uint64, match string, count int64, keyType string) (keys []string, cur uint64, err error)

func (*Redis) Set

func (r *Redis) Set(ctx context.Context, key, val string) error

func (*Redis) SetBit

func (r *Redis) SetBit(ctx context.Context, key string, offset int64, value int) (int64, error)

func (*Redis) SetEx

func (r *Redis) SetEx(ctx context.Context, key, val string, expSecond int) error

func (*Redis) SetNx

func (r *Redis) SetNx(ctx context.Context, key, val string) (bool, error)

func (*Redis) SetNxMs

func (r *Redis) SetNxMs(ctx context.Context, key, val string, expMill int) (bool, error)

func (*Redis) SetNxSec

func (r *Redis) SetNxSec(ctx context.Context, key, val string, expSecond int) (bool, error)

func (*Redis) SetRange

func (r *Redis) SetRange(ctx context.Context, key string, offset int64, value string) (int64, error)

func (*Redis) SetXx

func (r *Redis) SetXx(ctx context.Context, key, val string) (bool, error)

func (*Redis) SetXxMs

func (r *Redis) SetXxMs(ctx context.Context, key, val string, expMill int) (bool, error)

func (*Redis) SetXxSec

func (r *Redis) SetXxSec(ctx context.Context, key, val string, expSecond int) (bool, error)

func (*Redis) StrLen

func (r *Redis) StrLen(ctx context.Context, key string) (int64, error)

func (*Redis) TTL

func (r *Redis) TTL(ctx context.Context, key string) (int64, error)

func (*Redis) TryLock

func (r *Redis) TryLock(key string, lockVal *string, exp int, maxTryTime int, intervalMs int64) error

TryLock 尝试获取redis锁,指定重试次数和重试间隔,成功返回nil,否则返回对应error

func (r *Redis) Unlink(ctx context.Context, key ...string) (int64, error)

func (*Redis) WithLock

func (r *Redis) WithLock(key string, lockVal *string, exp int, maxTryTime int, intervalMs int64, fun func())

WithLock 尝试获取redis锁,指定重试次数和重试间隔,获取成功之后执行 fun,否则不执行

func (*Redis) ZAdd

func (r *Redis) ZAdd(ctx context.Context, key string, member interface{}, score float64) (int64, error)

zset funcs

func (*Redis) ZAddList

func (r *Redis) ZAddList(ctx context.Context, key string, memList ...map[string]interface{}) (int64, error)

ZAddList memList: {member: m1, score: 1}

func (*Redis) ZRangeByScore

func (r *Redis) ZRangeByScore(ctx context.Context, key, min, max string, offset, count int64) ([]string, error)

func (*Redis) ZRem

func (r *Redis) ZRem(ctx context.Context, key string, memberList ...interface{}) (int64, error)

func (*Redis) ZRemRangeByScore

func (r *Redis) ZRemRangeByScore(ctx context.Context, key, min, max string) (int64, error)

func (*Redis) ZScan

func (r *Redis) ZScan(ctx context.Context, key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error)

Jump to

Keyboard shortcuts

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