redistool

package
v0.0.0-...-b988991 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package redistool for process with redis

Index

Constants

View Source
const (
	REDIS_CONTAINER_STR = iota
	REDIS_CONTAINER_LIST
	REDIS_CONTAINER_SET
	REDIS_CONTAINER_HASH
)

Variables

View Source
var (
	TimeType = reflect.TypeOf(_TimeDefault)
)

Functions

func ConvertObjToInterfaceMap

func ConvertObjToInterfaceMap(obj interface{}) (map[string]interface{}, error)

func ConvertObjToStringMap

func ConvertObjToStringMap(obj interface{}) (map[string]string, error)

func ConvertRedisListToSlice

func ConvertRedisListToSlice(redisL []string, sliceObj interface{}) error

func ConvertSliceToRedisList

func ConvertSliceToRedisList(sliceObj interface{}) ([]string, error)

func ConvertStringMapToObj

func ConvertStringMapToObj(hashV map[string]string, objP interface{}) error

func ErrKeyNotExist

func ErrKeyNotExist(key string) error

func ErrTimeOut

func ErrTimeOut(key string) error

func ErrUnknown

func ErrUnknown(key string) error

func IsKeyNotExist

func IsKeyNotExist(err error) bool

func IsTimeOut

func IsTimeOut(err error) bool

Types

type ErrorType

type ErrorType int
const (
	UnknownType ErrorType = iota
	KeyNotExist
	TimeOut
)

func GetErrorType

func GetErrorType(err error) ErrorType

type GlobalLock

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

func NewGlobalLock

func NewGlobalLock(ownerName string, redisCmd redis.Cmdable, key string, holdDuration time.Duration,
	retryTimes int, retryIntvalDuration time.Duration) (*GlobalLock, error)

func (*GlobalLock) DoPreempt

func (gl *GlobalLock) DoPreempt(waitingLock bool) (bool, error)

func (*GlobalLock) Release

func (gl *GlobalLock) Release()

func (*GlobalLock) Result

func (gl *GlobalLock) Result() (bool, error)

func (*GlobalLock) StateChan

func (gl *GlobalLock) StateChan() <-chan GlobalLockState

type GlobalLockState

type GlobalLockState int
const (
	GlobalLockStatePreempting GlobalLockState = iota
	GloblaLockStateHold
	GlobalLockStateExpired
	GlobalLockStateFailure
)

type RedisCmd

type RedisCmd int

命令类型

const (
	REDIS_GET RedisCmd = iota
	REDIS_SET
	REDIS_SETNX
	REDIS_DEL
	REDIS_HGETALL // 得到完整的map数据
	REDIS_HMGET
	REDIS_HSET
	REDIS_HMSET
	REDIS_HDEL // 删除hash对象中的多个field
	REDIS_LGET // 得到完整的list数据
	REDIS_LSET // list的整体更新,把原有的key删除,重新设置
	REDIS_LRPUSH
	REDIS_LLPUSH
	REDIS_LREM      // 移除列表元素
	REDIS_LTRIM     // 保留列表指定区间的元素
	REDIS_LLEN      // 获取列表长度
	REDIS_LPOP      // 移出并获取第一个元素
	REDIS_SGET      // set的整体获取
	REDIS_SSET      // set的整体更新,把原有的key删除,重新设置
	REDIS_SISMEMBER // 判断是否再set中
	REDIS_SADD      // set add
	REDIS_SREM      // set remove
	REDIS_PIPELINE
	REDIS_CLUSTERSLOTS
	REDIS_EXISTS // 判断key是否存在
	REDIS_SCRIPT_LOAD
	REDIS_EVAlSHA
	REDIS_INCR
	REDIS_ZINCRBY     // 有序集合中对指定成员的分数加上增量 increment
	REDIS_ZSCORE      // 返回有序集中,成员的分数值
	REDIS_ZREM        // 移除有序集中的一个或多个成员
	REDIS_EXPIRE      // 设置Key生存时间
	REDIS_ZRRANK      // 返回倒序索引
	REDIS_SCAN        // key扫描
	REDIS_CLUSTERSCAN // cluster scan
	REDIS_DBSIZE      // key的数量
)

命令字

func (RedisCmd) String

func (i RedisCmd) String() string

type RedisCommandData

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

type RedisContainerType

type RedisContainerType int

type RedisMgr

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

func NewRedisMgr

func NewRedisMgr(redisSvrAddrs []string, sessionCount int, isCluster bool, password string) *RedisMgr

func (*RedisMgr) ClusterScan

func (rm *RedisMgr) ClusterScan(masterNodeCmdable redis.Cmdable, cursor uint64, match string, count int64) ([]string, uint64, error)

func (*RedisMgr) DBSize

func (rm *RedisMgr) DBSize() (int64, error)

func (*RedisMgr) DelKey

func (rm *RedisMgr) DelKey(key string) (int64, error)

0: key不存在,> 0 删除成功

func (*RedisMgr) Evalsha

func (rm *RedisMgr) Evalsha(args []interface{}) (interface{}, error)

func (*RedisMgr) Exists

func (rm *RedisMgr) Exists(key string) (int64, error)

0: 不存在 1: 存在

func (*RedisMgr) Expire

func (rm *RedisMgr) Expire(key string, seconds int) (bool, error)

func (*RedisMgr) GetClient

func (rm *RedisMgr) GetClient() *redis.Client

func (*RedisMgr) GetClusterClient

func (rm *RedisMgr) GetClusterClient() *redis.ClusterClient

func (*RedisMgr) HashDel

func (rm *RedisMgr) HashDel(key string, fields ...string) (int, error)

func (*RedisMgr) HashGetAll

func (rm *RedisMgr) HashGetAll(key string) (map[string]string, error)

func (*RedisMgr) HashMSet

func (rm *RedisMgr) HashMSet(key string, hashV map[string]interface{}) error

func (*RedisMgr) HashSet

func (rm *RedisMgr) HashSet(key string, fieldKey string, value interface{}) error

func (*RedisMgr) Incr

func (rm *RedisMgr) Incr(key string) (int, error)

func (*RedisMgr) ListGet

func (rm *RedisMgr) ListGet(key string) ([]string, error)

func (*RedisMgr) ListLPop

func (rm *RedisMgr) ListLPop(key string) (string, error)

func (*RedisMgr) ListLPushVariable

func (rm *RedisMgr) ListLPushVariable(key string, value ...string) (int, error)

func (*RedisMgr) ListLen

func (rm *RedisMgr) ListLen(key string) (int, error)

func (*RedisMgr) ListRPush

func (rm *RedisMgr) ListRPush(key string, value []string) (int, error)

func (*RedisMgr) ListRPushVariable

func (rm *RedisMgr) ListRPushVariable(key string, value ...string) (int, error)

func (*RedisMgr) ListRem

func (rm *RedisMgr) ListRem(key string, v string, count int) (int, error)

func (*RedisMgr) ListSet

func (rm *RedisMgr) ListSet(key string, value []string) error

func (*RedisMgr) ListTrim

func (rm *RedisMgr) ListTrim(key string, start, stop int) error

func (*RedisMgr) Pipelined

func (rm *RedisMgr) Pipelined(fn redisPipelineFn) ([]redis.Cmder, error)

func (*RedisMgr) SAdd

func (rm *RedisMgr) SAdd(key string, members ...interface{}) (int64, error)

func (*RedisMgr) SIsMember

func (rm *RedisMgr) SIsMember(key string, member interface{}) (bool, error)

func (*RedisMgr) SRem

func (rm *RedisMgr) SRem(key string, members ...interface{}) (int64, error)

func (*RedisMgr) Scan

func (rm *RedisMgr) Scan(cursor uint64, match string, count int64) ([]string, uint64, error)

func (*RedisMgr) ScriptLoad

func (rm *RedisMgr) ScriptLoad(script []byte) (interface{}, error)

func (*RedisMgr) Start

func (rm *RedisMgr) Start() error

func (*RedisMgr) Stop

func (rm *RedisMgr) Stop()

func (*RedisMgr) StringGet

func (rm *RedisMgr) StringGet(key string) (interface{}, error)

func (*RedisMgr) StringSet

func (rm *RedisMgr) StringSet(key string, value []byte) error

func (*RedisMgr) StringSetNX

func (rm *RedisMgr) StringSetNX(key string, value []byte, ttl int) error

func (*RedisMgr) ZIncrBy

func (rm *RedisMgr) ZIncrBy(key, member string, increment int) (int, error)

func (*RedisMgr) ZRem

func (rm *RedisMgr) ZRem(key string, members ...string) (int, error)

func (*RedisMgr) ZReverseRank

func (rm *RedisMgr) ZReverseRank(key string, member string) (int, error)

func (*RedisMgr) ZScore

func (rm *RedisMgr) ZScore(key, member string) (int, error)

type RedisResultS

type RedisResultS struct {
	Ok     bool
	Result interface{}
}

内部返回类型

type RedisScanResult

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

Jump to

Keyboard shortcuts

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