-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbit.go
34 lines (28 loc) · 840 Bytes
/
bit.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
package redigo_pack
import "github.com/garyburd/redigo/redis"
type bitRds struct {
}
func (b *bitRds) SetBit(key string, offset, value int64) *Reply {
c := pool.Get()
defer c.Close()
return getReply(c.Do("setbit", key, offset, value))
}
func (b *bitRds) GetBit(key string, offset int64) *Reply {
c := pool.Get()
defer c.Close()
return getReply(c.Do("getbit", key, offset))
}
func (b *bitRds) BitCount(key string, interval ...int64) *Reply {
c := pool.Get()
defer c.Close()
if len(interval) == 2 {
return getReply(c.Do("bitcount", key, interval[0], interval[1]))
}
return getReply(c.Do("bitcount", key))
}
// opt 包含 and、or、xor、not
func (b *bitRds) BitTop(opt, destKey string, keys ...string) *Reply {
c := pool.Get()
defer c.Close()
return getReply(c.Do("bitop", opt, redis.Args{}.Add(keys).AddFlat(keys)))
}