Documentation ¶
Index ¶
- Variables
- func DefaultInit()
- func Del(key string) (err error)
- func Exists(key string) (exist bool, err error)
- func FlushDbV2() (err error)
- func Get(key string) (value string, err error)
- func GetGob(key string, obj interface{}) (err error)
- func GetGobIgnoreNotExist(key string, obj interface{}) (err error)
- func GetJson(key string, obj interface{}) (err error)
- func HGetAll(key string) (map[string]string, error)
- func IncrBy(key string, num int64) (err error)
- func IncrByFloat(key string, num float64) (err error)
- func InitWithConfig(opt *redis.Options)
- func InitWithDbNum(num int)
- func Insert(key string, value string) (err error)
- func InsertGob(key string, obj interface{}) (err error)
- func Keys(searchKey string) (keyList []string, err error)
- func LRangeAll(key string) (out []string, err error)
- func LRangeAllGob(key string, list interface{}) (err error)
- func ListGobUnmarshalNotExistCheck(outList []interface{}, obj reflect.Value) (err error)
- func MGetNotExistCheck(keyList []string) (value []string, err error)
- func MGetNotExistCheckGob(keyList []string, obj interface{}) (err error)
- func MustDel(key string)
- func MustFlushDb(c *redis.Client)
- func MustFlushDbV2()
- func MustGet(key string) (value string)
- func MustGetAllMemberFromSortedSet(key string) (sList []string)
- func MustGetAllZRange(c *redis.Client, key string) []string
- func MustGetData(c *redis.Client, key string) string
- func MustGetDataWithGob(c *redis.Client, key string, inData interface{})
- func MustGetFloatIgnoreNotExist(key string) float64
- func MustGetGob(key string, obj interface{})
- func MustGetIntIgnoreNotExist(key string) (valueI int)
- func MustGetSortedSetSize(key string) int
- func MustHGetAll(key string) map[string]string
- func MustHSet(key1 string, key2 string, value string)
- func MustInsert(key string, value string)
- func MustInsertGob(key string, obj interface{})
- func MustInsertJson(key string, obj interface{})
- func MustKeys(searchKey string) (kList []string)
- func MustMSet(pairList []KeyValuePair)
- func MustSAdd(key string, value string)
- func MustSMembers(key string) (sList []string)
- func MustSet(key string, value string)
- func MustSetData(c *redis.Client, key string, data string)
- func MustSetDataWithGob(c *redis.Client, key string, data interface{})
- func MustSetDbData(c *redis.Client, data map[string]string)
- func MustSetDbDataYaml(c *redis.Client, yaml string)
- func MustSetGob(key string, obj interface{})
- func MustUpdate(key string, value string)
- func MustUpdateJson(key string, obj interface{})
- func MustZAdd(key string, score float64, member string)
- func MustZRemRangeByScore(key string, min float64, max float64)
- func MustZScore(key string, member string) (f float64)
- func RPush(key string, value string) (err error)
- func RPushGob(key string, value interface{}) (err error)
- func RenameNx(key string, newKey string) (err error)
- func SAdd(key string, value string) (err error)
- func ScanCallback(patten string, cb func(key string) error) (err error)
- func ScanWithOutputLimit(pattern string, limit int) (sList []string, err error)
- func Set(key string, value string) (err error)
- func SetEx(key string, dur time.Duration, value string) (err error)
- func SetGob(key string, obj interface{}) (err error)
- func TestInit()
- func Update(key string, value string) (err error)
- func UpdateGob(key string, obj interface{}) (err error)
- func ZAdd(key string, score float64, member string) (err error)
- func ZRange(key string, start int, end int) (sList []string, err error)
- func ZRangeByScore(key string, min float64, max float64) (sList []string, err error)
- func ZRevRange(key string, start int, end int) (sList []string, err error)
- func ZRevRangeByScore(key string, min float64, max float64) (sList []string, err error)
- func ZScanCallback(key string, cb func(member string) error) (err error)
- func ZScore(key string, member string) (f float64, err error)
- type KeyValuePair
- type Z
- func GetAllScoreAndMemberFromSortedSet(key string) (outList []Z, err error)
- func GetRevAllScoreAndMemberFromSortedSet(key string) (outList []Z, err error)
- func ZListFromRedisZ(list []redis.Z) []Z
- func ZRangeByScoreWithScore(key string, min float64, max float64) (zList []Z, err error)
- func ZRevRangeWithScore(key string, start int, end int) (outList []Z, err error)
Constants ¶
This section is empty.
Variables ¶
var ErrKeyExist = errors.New("key exist")
var ErrKeyNotExist = errors.New("key not exist")
var ErrListWrongType = errors.New("WRONGTYPE Operation against a key holding the wrong kind of value,need a list type")
var ErrRenameSameName = errors.New("ERR source and destination objects are the same")
var ErrSortedSetWrongType = errors.New("WRONGTYPE Operation against a key holding the wrong kind of value,need a sorted set type")
var ErrStringWrongType = errors.New("WRONGTYPE Operation against a key holding the wrong kind of value,need a string type")
var ErrValueNotFloatFormat = errors.New("ERR value is not a valid float")
var ErrValueNotIntFormatOrOutOfRange = errors.New("ERR value is not an integer or out of range")
Functions ¶
func DefaultInit ¶
func DefaultInit()
func Get ¶
从redis的kvdb中获取一个key 注意 value有可能是 "" 这个和数据不存在是两种情况. 如果数据不存在,会返回ErrKeyNotExist value在redis里面不是string类型,会返回 ErrStringWrongType 网络错误也会返回 error
func GetGobIgnoreNotExist ¶
func IncrBy ¶
给某一个redis的key加一个整数 key不存在,会先把这个key变成0,然后再进行增加 key不能被解析成整数,会返回 ErrValueNotIntFormatOrOutOfRange value不是string类型,会返回 ErrStringWrongType 网络错误会返回error
func IncrByFloat ¶
给某一个redis的key加一个浮点 不要传入大于1e200的浮点,会挂掉. TODO 解决这个问题? key不存在,会先把这个key变成0,然后再进行增加 key不能被解析成整数,会返回 ErrValueNotFloatFormatOrOutOfRange value不是string类型,会返回 ErrStringWrongType 网络错误会返回error
func InitWithConfig ¶
func InitWithConfig(opt *redis.Options)
func InitWithDbNum ¶
func InitWithDbNum(num int)
func Keys ¶
使用 redis的表达式搜索key,返回搜索到的key的列表 只有网络问题会返回error ** 仅适用于整个数据库key数量比较少的数据库(<500k条数据),否则非常慢. **
func LRangeAll ¶
返回一个redis数组里面所有的值. 查询的key存在,并且类型正确,返回列表里面的数据 查询的key不存在,返回空数组 TODO 好用? 查询的key类型错误,返回 ErrListWrongType 网络错误会返回error
func LRangeAllGob ¶
func MGetNotExistCheck ¶
一次操作,批量从redis里面返回大量key的值. 没有传入数据,不报错 如果查询的key全部存在,返回数据. 如果存在某一个key不存在,或者类型错误,返回 ErrKeyNotExist ,value里面什么也没有 (和redis命令不一致) 网络错误会返回error
func MGetNotExistCheckGob ¶
带超时的设置一条数据 没有传入数据,不报错,不修改obj 网络错误会返回error
func MustFlushDbV2 ¶
func MustFlushDbV2()
func MustGetDataWithGob ¶
func MustGetDataWithGob(c *redis.Client, key string, inData interface{})
@deprecated
func MustGetFloatIgnoreNotExist ¶
从redis的kvdb中获取一个key 将这个key转换成float 无法转换成float,会panic key不存在,返回0 网络错误会panic
func MustGetGob ¶
func MustGetGob(key string, obj interface{})
func MustGetIntIgnoreNotExist ¶
从redis的kvdb中获取一个key 将这个key转换成int 无法转换成int,会panic key不存在,返回0 网络错误会panic
func MustGetSortedSetSize ¶
func MustHGetAll ¶
func MustInsert ¶
func MustInsertGob ¶
func MustInsertGob(key string, obj interface{})
func MustInsertJson ¶
func MustInsertJson(key string, obj interface{})
func MustSMembers ¶
func MustSetDataWithGob ¶
func MustSetDataWithGob(c *redis.Client, key string, data interface{})
func MustSetDbData ¶
清空当前db的所有数据,并且设置为传入的数据 这个函数主要用于测试 @deprecated
func MustSetGob ¶
func MustSetGob(key string, obj interface{})
func MustUpdate ¶
func MustUpdateJson ¶
func MustUpdateJson(key string, obj interface{})
func MustZRemRangeByScore ¶
func MustZScore ¶
func RPush ¶
Insert all the specified values at the tail of the list stored at key. If key does not exist, it is created as empty list before performing the push operation. When key holds a value that is not a list, an error is returned. 更改的key存在,会向这个数组类型的key,右边加入一个元素. 更改的key不存在,会创建一个,并且写入第一个值. 更改的key的类型不正确会返回 ErrListWrongType 网络错误会返回error
func RenameNx ¶
改key的名字 key不存在 ErrKeyNotExist key和newKey一样 ErrRenameSameName newKey存在 ErrKeyExist 网络错误会返回error
func ScanCallback ¶
扫描redis里面所有的key. 目前按照10000个一次的速度进行出来.
func ScanWithOutputLimit ¶
保证只会返回小于等于limit个数据.
func ZRangeByScore ¶
func ZRevRangeByScore ¶
Types ¶
type KeyValuePair ¶
type Z ¶
func GetAllScoreAndMemberFromSortedSet ¶
正向读取跳跃表中所有数据 读取一条不是sortset的数据,会返回 ErrSortedSetWrongType 网络错误会返回error
func GetRevAllScoreAndMemberFromSortedSet ¶
逆向读取跳跃表中所有数据 读取一条不是sortset的数据,会返回 ErrSortedSetWrongType 网络错误会返回error
func ZListFromRedisZ ¶
func ZListFromRedisZ(list []redis.Z) []Z