-
Notifications
You must be signed in to change notification settings - Fork 2
/
set.go
executable file
·90 lines (75 loc) · 2.63 KB
/
set.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package Redis
import "github.com/redigo/redis"
func (r *RedisType) SAdd (key string, members ...interface {}) (int, error){
params := make([]interface {},0)
params = append(params,key)
for _,v := range members{ params = append(params, v) }
row,err := redis.Int(r.RedisConn.Do("SADD",params...))
return row, err
}
func (r *RedisType) SCard (key string) (int,error){
row,err := redis.Int(r.RedisConn.Do("SCARD",key))
return row, err
}
func (r *RedisType) SDiff (key ...interface {}) (interface {},error) {
row,err := r.RedisConn.Do("SDIFF",key)
return row, err
}
func (r *RedisType) SDiffStore (destination string,key ...interface {}) (int,error) {
row,err := redis.Int(r.RedisConn.Do("SDIFFSTORE",destination,key))
return row, err
}
func (r *RedisType) SInter (key ...interface {}) (interface {},error) {
row,err := r.RedisConn.Do("SINTER",key)
return row, err
}
func (r *RedisType) SInterScore (destination string,key ...interface {}) (int,error) {
row,err := redis.Int(r.RedisConn.Do("SINTERSTORE",destination,key))
return row, err
}
func (r *RedisType) SIsMember (key string, member interface {}) (bool,error){
row,err := redis.Bool(r.RedisConn.Do("SISMEMBER",key, member))
return row, err
}
func (r *RedisType) SMembers (key string) ([]string,error){
row,err := redis.Strings(r.RedisConn.Do("SMEMBERS",key))
if err == redis.ErrNil{ return nil, nil }
return row, err
}
func (r *RedisType) SMove (source,destination string, member interface {}) (int,error) {
row,err := redis.Int(r.RedisConn.Do("SMOVE", source, destination, member))
return row, err
}
func (r *RedisType) SPop (key string) (string,error){
row,err := redis.String(r.RedisConn.Do("SPOP",key))
if err == redis.ErrNil{ return "", nil }
return row, err
}
func (r *RedisType) SRandMember (key string, count ...int) (interface {},error){
if len(count) > 0{
row,err := redis.Strings(r.RedisConn.Do("SRANDMEMBER",key,count[0]))
return row,err
} else {
row, err := redis.String(r.RedisConn.Do("SRANDMEMBER", key))
return row, err
}
}
func (r *RedisType) SRem (key string,members ...interface {}) (int,error){
params := make([]interface {},0)
params = append(params,key)
for _,v := range members{ params = append(params,v) }
row,err := redis.Int(r.RedisConn.Do("SREM",params...))
return row, err
}
func (r *RedisType) SUnion (key ...interface {}) (interface {},error){
row,err := r.RedisConn.Do("SUNION",key...)
return row, err
}
func (r *RedisType) SUnionStore (destination,key string) (int,error){
row,err := redis.Int(r.RedisConn.Do("SUNIONSTORE",destination,key))
return row, err
}
//SSCAN key cursor [MATCH pattern] [COUNT count]
//func (r *RedisType) SScan () () {
//
//}