mirror of
https://github.com/redis/go-redis.git
synced 2025-04-17 20:17:02 +03:00
Signed-off-by: monkey92t <golang@88.com> Co-authored-by: Vladimir Mihailenco <vladimir.webdev@gmail.com>
This commit is contained in:
parent
683f4fa6a6
commit
6833d2f8e1
@ -45,22 +45,19 @@ const BitCountIndexByte string = "BYTE"
|
|||||||
const BitCountIndexBit string = "BIT"
|
const BitCountIndexBit string = "BIT"
|
||||||
|
|
||||||
func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd {
|
func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd {
|
||||||
args := []interface{}{"bitcount", key}
|
args := make([]any, 2, 5)
|
||||||
|
args[0] = "bitcount"
|
||||||
|
args[1] = key
|
||||||
if bitCount != nil {
|
if bitCount != nil {
|
||||||
if bitCount.Unit == "" {
|
args = append(args, bitCount.Start, bitCount.End)
|
||||||
bitCount.Unit = "BYTE"
|
if bitCount.Unit != "" {
|
||||||
|
if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit {
|
||||||
|
cmd := NewIntCmd(ctx)
|
||||||
|
cmd.SetErr(errors.New("redis: invalid bitcount index"))
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
args = append(args, bitCount.Unit)
|
||||||
}
|
}
|
||||||
if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit {
|
|
||||||
cmd := NewIntCmd(ctx)
|
|
||||||
cmd.SetErr(errors.New("redis: invalid bitcount index"))
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
args = append(
|
|
||||||
args,
|
|
||||||
bitCount.Start,
|
|
||||||
bitCount.End,
|
|
||||||
string(bitCount.Unit),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
cmd := NewIntCmd(ctx, args...)
|
cmd := NewIntCmd(ctx, args...)
|
||||||
_ = c(ctx, cmd)
|
_ = c(ctx, cmd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user