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
- Variables
- func ConvertObjToRedisHash(obj interface{}) (map[string]string, error)
- func ConvertRedisHashToObj(hashV map[string]string, objP interface{}) error
- func ConvertRedisListToSlice(redisL []string, sliceObj interface{}) error
- func ConvertSliceToRedisList(sliceObj interface{}) ([]string, error)
- func ErrKeyNotExist(key string) error
- func ErrTimeOut(key string) error
- func ErrUnknown(key string) error
- func IsKeyNotExist(err error) bool
- func IsTimeOut(err error) bool
- func SafeLock(key string, value string, ttl int) error
- func SpinLock(key string, value string, ttl int) error
- func SpinLockWithFingerPoint(key string, ttl int) (string, error)
- func UnLock(key string, value string) error
- type ErrorType
- type RedisCluster
- type RedisClusterNodeS
- type RedisClusterSlotS
- type RedisCmd
- type RedisCommandData
- type RedisContainerType
- type RedisManager
- type RedisNode
- func (rn *RedisNode) Addr() string
- func (rn *RedisNode) ClusterSlots() ([]*RedisClusterSlotS, error)
- func (rn *RedisNode) DelKey(key string) error
- func (rn *RedisNode) Evalsha(args []interface{}) (interface{}, error)
- func (rn *RedisNode) Exists(key string) (bool, error)
- func (rn *RedisNode) Expire(key string, seconds int) error
- func (rn *RedisNode) HashDel(key string, fields ...string) (int, error)
- func (rn *RedisNode) HashGet(key string) (map[string]string, error)
- func (rn *RedisNode) HashGetFields(key string, fields ...string) ([]string, error)
- func (rn *RedisNode) HashSet(key string, hashV map[string]string) error
- func (rn *RedisNode) Incr(key string) (int, error)
- func (rn *RedisNode) ListGet(key string) ([]string, error)
- func (rn *RedisNode) ListLPop(key string) (string, error)
- func (rn *RedisNode) ListLPushVariable(key string, value ...string) (int, error)
- func (rn *RedisNode) ListLen(key string) (int, error)
- func (rn *RedisNode) ListRPush(key string, value []string) (int, error)
- func (rn *RedisNode) ListRPushVariable(key string, value ...string) (int, error)
- func (rn *RedisNode) ListRem(key string, v string, count int) (int, error)
- func (rn *RedisNode) ListSet(key string, value []string) error
- func (rn *RedisNode) ListTrim(key string, start, stop int) error
- func (rn *RedisNode) ScriptLoad(script []byte) (interface{}, error)
- func (rn *RedisNode) Start() error
- func (rn *RedisNode) Stop()
- func (rn *RedisNode) StringGet(key string) (interface{}, error)
- func (rn *RedisNode) StringSet(key string, value []byte) error
- func (rn *RedisNode) StringSetNX(key string, value []byte, ttl int) error
- func (rn *RedisNode) ZIncrBy(key, member string, increment int) (int, error)
- func (rn *RedisNode) ZRem(key string, members ...string) (int, error)
- func (rn *RedisNode) ZReverseRank(key string, member string) (int, error)
- func (rn *RedisNode) ZScore(key, member string) (int, error)
- type RedisPipeLine
- type RedisPipeLineExecResult
- type RedisPipeLineParamS
- type RedisPipeLineResultS
- type RedisResultS
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 ConvertRedisHashToObj ¶
func ConvertRedisListToSlice ¶
func ConvertSliceToRedisList ¶
func ErrKeyNotExist ¶
func ErrTimeOut ¶
func ErrUnknown ¶
func IsKeyNotExist ¶
Types ¶
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 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 // 返回倒序索引 )
命令字
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 (*RedisNode) ClusterSlots ¶
func (rn *RedisNode) ClusterSlots() ([]*RedisClusterSlotS, error)
func (*RedisNode) HashGetFields ¶
func (*RedisNode) ListLPushVariable ¶
func (*RedisNode) ListRPushVariable ¶
func (*RedisNode) ScriptLoad ¶
func (*RedisNode) StringSetNX ¶
func (*RedisNode) ZReverseRank ¶
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 ¶
func (rpl *RedisPipeLine) Run(rn *RedisNode) (RedisPipeLineExecResult, error)
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)
Click to show internal directories.
Click to hide internal directories.