|
@ -126,6 +126,35 @@ func HGetList(key string) ([]string, error) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//hash取所有值
|
|
|
|
|
|
|
|
|
|
|
|
func HGetAllItem(key string) (map[string]string, error) { |
|
|
|
|
|
c := GetConn() |
|
|
|
|
|
|
|
|
|
|
|
ret, err := c.Do("HGETAll", key) |
|
|
|
|
|
|
|
|
|
|
|
reply := make([][]byte, 0) |
|
|
|
|
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|
|
reply, err = redisdb.ByteSlices(ret, err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var info map[string]string = make(map[string]string) |
|
|
|
|
|
|
|
|
|
|
|
if len(reply) > 0 { |
|
|
|
|
|
for key, item := range reply { |
|
|
|
|
|
if key%2 == 0 { //只处理奇数位
|
|
|
|
|
|
info[string(item)] = string(reply[key+1]) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CloseConn(c) |
|
|
|
|
|
return info, err |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
* hash存值, |
|
|
* hash存值, |
|
|
* key 域 |
|
|
* key 域 |
|
@ -198,6 +227,39 @@ func HMSet(args ...interface{}) (interface{}, error) { |
|
|
return reply, err |
|
|
return reply, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* hash批量查询, |
|
|
|
|
|
* args (key,field,field,field...) 域,名,名,名 ... |
|
|
|
|
|
* 2020/06/06 |
|
|
|
|
|
*/ |
|
|
|
|
|
func HMGet(args ...interface{}) (interface{}, error) { |
|
|
|
|
|
c := GetConn() |
|
|
|
|
|
|
|
|
|
|
|
reply, err := c.Do("HMGET", args...) |
|
|
|
|
|
CloseConn(c) |
|
|
|
|
|
return reply, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* hash批量查询, |
|
|
|
|
|
* args (key,field,field,field...) 域,名,名,名 ... |
|
|
|
|
|
* 2020/06/06 |
|
|
|
|
|
*/ |
|
|
|
|
|
func HMGetString(args ...interface{}) ([]string, error) { |
|
|
|
|
|
c := GetConn() |
|
|
|
|
|
|
|
|
|
|
|
reply, err := c.Do("HMGET", args...) |
|
|
|
|
|
CloseConn(c) |
|
|
|
|
|
|
|
|
|
|
|
list := make([]string, 0) |
|
|
|
|
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|
|
list, err = redisdb.Strings(reply, err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return list, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
* hash存值, |
|
|
* hash存值, |
|
|
* key 域 |
|
|
* key 域 |
|
|