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: 12 Imported by: 0

Documentation

Overview

* @Author: calmwu * @Date: 2017-10-27 15:37:01 * @Last Modified by: calmwu * @Last Modified time: 2017-10-27 17:29:11 * @Comment:

* @Author: calmwu * @Date: 2017-10-23 15:01:03 * @Last Modified by: calmwu * @Last Modified time: 2017-11-09 12:53:21 * @Comment:

* @Author: calmwu * @Date: 2017-10-27 15:02:57 * @Last Modified by: calmwu * @Last Modified time: 2017-10-27 17:01:41 * @Comment:

Index

Constants

View Source
const (
	REDIS_CONTAINER_STR = iota
	REDIS_CONTAINER_LIST
	REDIS_CONTAINER_SET
	REDIS_CONTAINER_HASH
)
View Source
const (
	//这个锁采用自旋锁实现,高效.
	//为了避免异常时死锁,这里设置下最大的自旋次数
	//kSnoozeTime, 这里设置100毫秒旋一次
	SnoozeTime   = 100
	TryLockTimes = 20
)
View Source
const (
	HSCAN_BATCHCOUNT = 100
)
View Source
const (
	LSCAN_BATCHCOUNT = 100
)
View Source
const (
	REDIS_CLUSTER_SLOT_COUNT = 16384
)
View Source
const (
	REDIS_SESSION_COUNT = 20
)

Variables

View Source
var (
	SafeUnlockRoutine     string = "local fp = redis.pcall('get', KEYS[1]) if not fp or fp ~= ARGV[1] then return end return redis.pcall('del', KEYS[1])"
	GSafeUnlockRoutineSHA []byte = nil
)
View Source
var (
	GRedisManager = new(RedisManager)
)
View Source
var (
	TimeType = reflect.TypeOf(c_TIME_DEFAULT)
)

Functions

func ConvertObjToRedisHash

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

func ConvertRedisHashToObj

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

func ConvertRedisListToSlice

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

func ConvertSliceToRedisList

func ConvertSliceToRedisList(sliceObj interface{}) ([]string, 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

func SafeLock

func SafeLock(key string, value string, ttl int) error

func SpinLock

func SpinLock(key string, value string, ttl int) error

func SpinLockWithFingerPoint

func SpinLockWithFingerPoint(key string, ttl int) (string, error)

func UnLock

func UnLock(key string, value string) error

Types

type ErrorType

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

func GetErrorType

func GetErrorType(err error) ErrorType

type RedisCluster

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

func GetRedisCluster

func GetRedisCluster(redisNodes []*RedisNode) (*RedisCluster, error)

func (*RedisCluster) GetRedisNodeByKey

func (rc *RedisCluster) GetRedisNodeByKey(rKey interface{}) (*RedisNode, error)

type RedisClusterNodeS

type RedisClusterNodeS struct {
	IP   string
	Port int64
	Key  string
}

type RedisClusterSlotS

type RedisClusterSlotS struct {
	RedisSvrAddr string
	BeginPos     int64
	EndPos       int64
	NodeInfo     RedisClusterNodeS
}

type RedisCmd

type RedisCmd int

命令类型

const (
	REDIS_GET RedisCmd = iota
	REDIS_SET
	REDIS_SETNX
	REDIS_DEL
	REDIS_HGET // 得到完整的map数据
	REDIS_HMGET
	REDIS_HSET // hash对象的完整更新
	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_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  // 返回倒序索引
)

命令字

func (RedisCmd) String

func (rc RedisCmd) String() string

type RedisCommandData

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

type RedisContainerType

type RedisContainerType int

type RedisManager

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

func (*RedisManager) GetClusterRedisMgr

func (redisManager *RedisManager) GetClusterRedisMgr(key string) (*RedisNode, error)

func (*RedisManager) GetSingletonRedisMgr

func (redisManager *RedisManager) GetSingletonRedisMgr() (*RedisNode, error)

func (*RedisManager) Initialize

func (redisManager *RedisManager) Initialize() error

type RedisNode

type RedisNode struct {
	RedisSvrAddr string
	// contains filtered or unexported fields
}

func NewRedis

func NewRedis(RedisSvrAddr string, sessionCount int) *RedisNode

func (*RedisNode) Addr

func (rn *RedisNode) Addr() string

func (*RedisNode) ClusterSlots

func (rn *RedisNode) ClusterSlots() ([]*RedisClusterSlotS, error)

func (*RedisNode) DelKey

func (rn *RedisNode) DelKey(key string) error

func (*RedisNode) Evalsha

func (rn *RedisNode) Evalsha(args []interface{}) (interface{}, error)

func (*RedisNode) Exists

func (rn *RedisNode) Exists(key string) (bool, error)

func (*RedisNode) Expire

func (rn *RedisNode) Expire(key string, seconds int) error

func (*RedisNode) HashDel

func (rn *RedisNode) HashDel(key string, fields ...string) (int, error)

func (*RedisNode) HashGet

func (rn *RedisNode) HashGet(key string) (map[string]string, error)

func (*RedisNode) HashGetFields

func (rn *RedisNode) HashGetFields(key string, fields ...string) ([]string, error)

func (*RedisNode) HashSet

func (rn *RedisNode) HashSet(key string, hashV map[string]string) error

func (*RedisNode) Incr

func (rn *RedisNode) Incr(key string) (int, error)

func (*RedisNode) ListGet

func (rn *RedisNode) ListGet(key string) ([]string, error)

func (*RedisNode) ListLPop

func (rn *RedisNode) ListLPop(key string) (string, error)

func (*RedisNode) ListLPushVariable

func (rn *RedisNode) ListLPushVariable(key string, value ...string) (int, error)

func (*RedisNode) ListLen

func (rn *RedisNode) ListLen(key string) (int, error)

func (*RedisNode) ListRPush

func (rn *RedisNode) ListRPush(key string, value []string) (int, error)

func (*RedisNode) ListRPushVariable

func (rn *RedisNode) ListRPushVariable(key string, value ...string) (int, error)

func (*RedisNode) ListRem

func (rn *RedisNode) ListRem(key string, v string, count int) (int, error)

func (*RedisNode) ListSet

func (rn *RedisNode) ListSet(key string, value []string) error

func (*RedisNode) ListTrim

func (rn *RedisNode) ListTrim(key string, start, stop int) error

func (*RedisNode) ScriptLoad

func (rn *RedisNode) ScriptLoad(script []byte) (interface{}, error)

func (*RedisNode) Start

func (rn *RedisNode) Start() error

func (*RedisNode) Stop

func (rn *RedisNode) Stop()

func (*RedisNode) StringGet

func (rn *RedisNode) StringGet(key string) (interface{}, error)

func (*RedisNode) StringSet

func (rn *RedisNode) StringSet(key string, value []byte) error

func (*RedisNode) StringSetNX

func (rn *RedisNode) StringSetNX(key string, value []byte, ttl int) error

func (*RedisNode) ZIncrBy

func (rn *RedisNode) ZIncrBy(key, member string, increment int) (int, error)

func (*RedisNode) ZRem

func (rn *RedisNode) ZRem(key string, members ...string) (int, error)

func (*RedisNode) ZReverseRank

func (rn *RedisNode) ZReverseRank(key string, member string) (int, error)

func (*RedisNode) ZScore

func (rn *RedisNode) ZScore(key, member string) (int, error)

type RedisPipeLine

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

func NewRedisPipeLine

func NewRedisPipeLine() *RedisPipeLine

func (*RedisPipeLine) Append

func (rpl *RedisPipeLine) Append(containerType RedisContainerType, redisCmd string, key string, value ...interface{}) error

func (*RedisPipeLine) Run

type RedisPipeLineExecResult

type RedisPipeLineExecResult []*RedisPipeLineResultS

type RedisPipeLineParamS

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

type RedisPipeLineResultS

type RedisPipeLineResultS struct {
	RedisCmd      string
	ContainerType RedisContainerType
	Key           string
	// contains filtered or unexported fields
}

func (*RedisPipeLineResultS) Error

func (rplR *RedisPipeLineResultS) Error() error

func (*RedisPipeLineResultS) Hash

func (rplR *RedisPipeLineResultS) Hash() (map[string]string, error)

func (*RedisPipeLineResultS) List

func (rplR *RedisPipeLineResultS) List() ([]string, error)

func (*RedisPipeLineResultS) String

func (rplR *RedisPipeLineResultS) String() (string, error)

type RedisResultS

type RedisResultS struct {
	Ok     bool
	Result interface{}
}

内部返回类型

Jump to

Keyboard shortcuts

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