mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-28 01:44:47 +08:00
新增接口
This commit is contained in:
@@ -1194,6 +1194,21 @@ func (slf *RedisModule) ZRange(key string, start, stop int, ascend bool, withSco
|
|||||||
return makeListJson(reply.([]interface{}), withScores), nil
|
return makeListJson(reply.([]interface{}), withScores), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取有序集合长度
|
||||||
|
func (slf *RedisModule) Zcard(key string) (int, error) {
|
||||||
|
conn, err := slf.getConn()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
reply, err := conn.Do("ZCARD", key)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(reply.(int64)), nil
|
||||||
|
}
|
||||||
|
|
||||||
//["123","234"]
|
//["123","234"]
|
||||||
func makeListJson(redisReply []interface{}, withScores bool) []byte {
|
func makeListJson(redisReply []interface{}, withScores bool) []byte {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
@@ -1417,24 +1432,23 @@ func (slf *RedisModule) ListPop(key string, fromLeft, block bool, timeout int) (
|
|||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (slf *RedisModule) HincrbyHashInt(redisKey, hashKey string, value int) error {
|
func (slf *RedisModule) HincrbyHashInt(redisKey, hashKey string, value int) error {
|
||||||
if redisKey == "" || hashKey == "" {
|
if redisKey == "" || hashKey == "" {
|
||||||
return errors.New("Key Is Empty")
|
return errors.New("Key Is Empty")
|
||||||
}
|
}
|
||||||
conn, err := slf.getConn()
|
conn, err := slf.getConn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
_, retErr := conn.Do("HINCRBY", redisKey, hashKey, value)
|
_, retErr := conn.Do("HINCRBY", redisKey, hashKey, value)
|
||||||
if retErr != nil {
|
if retErr != nil {
|
||||||
service.GetLogger().Printf(service.LEVER_ERROR, "HincrbyHashInt fail,reason:%v", retErr)
|
service.GetLogger().Printf(service.LEVER_ERROR, "HincrbyHashInt fail,reason:%v", retErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return retErr
|
return retErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (slf *RedisModule) EXPlREInsert(key string, TTl int) error {
|
func (slf *RedisModule) EXPlREInsert(key string, TTl int) error {
|
||||||
conn, err := slf.getConn()
|
conn, err := slf.getConn()
|
||||||
@@ -1449,4 +1463,15 @@ func (slf *RedisModule) HincrbyHashInt(redisKey, hashKey string, value int) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (slf *RedisModule) Zremrangebyrank(redisKey string, start, end interface{}) (int, error) {
|
||||||
|
conn, err := slf.getConn()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
reply, err := conn.Do("ZREMRANGEBYRANK", redisKey, start, end)
|
||||||
|
return redis.Int(reply, err)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user