hash.go
746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package zredis
import (
"github.com/gomodule/redigo/redis"
)
// HSet HSet
func HSet(tableName, key, value any) error {
conn, err := GetConn()
if err != nil {
return err
}
defer autoClose(conn)
_, err = conn.Do("HSET", tableName, key, value)
return err
}
// HGet HGet
func HGet(tableName, key any) any {
conn, err := GetConn()
if err != nil {
return nil
}
defer autoClose(conn)
reply, err := conn.Do("HGET", tableName, key)
if err != nil {
return nil
}
return reply
}
// HGetInt64 HGetInt64
func HGetInt64(tableName, key any) int64 {
conn, err := GetConn()
if err != nil {
return 0
}
defer autoClose(conn)
reply, err := redis.Int64(conn.Do("HGET", tableName, key))
if err == nil {
return reply
}
return 0
}