mirror of https://github.com/go-redis/redis.git
Remove manual strconv
This commit is contained in:
parent
2cf5af9928
commit
14f25982cb
19
commands.go
19
commands.go
|
@ -2,7 +2,6 @@ package redis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/internal"
|
"github.com/go-redis/redis/internal"
|
||||||
|
@ -19,24 +18,24 @@ func usePrecise(dur time.Duration) bool {
|
||||||
return dur < time.Second || dur%time.Second != 0
|
return dur < time.Second || dur%time.Second != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatMs(dur time.Duration) string {
|
func formatMs(dur time.Duration) int64 {
|
||||||
if dur > 0 && dur < time.Millisecond {
|
if dur > 0 && dur < time.Millisecond {
|
||||||
internal.Logf(
|
internal.Logf(
|
||||||
"specified duration is %s, but minimal supported value is %s",
|
"specified duration is %s, but minimal supported value is %s",
|
||||||
dur, time.Millisecond,
|
dur, time.Millisecond,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return strconv.FormatInt(int64(dur/time.Millisecond), 10)
|
return int64(dur / time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatSec(dur time.Duration) string {
|
func formatSec(dur time.Duration) int64 {
|
||||||
if dur > 0 && dur < time.Second {
|
if dur > 0 && dur < time.Second {
|
||||||
internal.Logf(
|
internal.Logf(
|
||||||
"specified duration is %s, but minimal supported value is %s",
|
"specified duration is %s, but minimal supported value is %s",
|
||||||
dur, time.Second,
|
dur, time.Second,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return strconv.FormatInt(int64(dur/time.Second), 10)
|
return int64(dur / time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Cmdable interface {
|
type Cmdable interface {
|
||||||
|
@ -1340,7 +1339,7 @@ func (c *cmdable) ZInterStore(destination string, store ZStore, keys ...string)
|
||||||
args := make([]interface{}, 3+len(keys))
|
args := make([]interface{}, 3+len(keys))
|
||||||
args[0] = "zinterstore"
|
args[0] = "zinterstore"
|
||||||
args[1] = destination
|
args[1] = destination
|
||||||
args[2] = strconv.Itoa(len(keys))
|
args[2] = len(keys)
|
||||||
for i, key := range keys {
|
for i, key := range keys {
|
||||||
args[3+i] = key
|
args[3+i] = key
|
||||||
}
|
}
|
||||||
|
@ -1536,7 +1535,7 @@ func (c *cmdable) ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd
|
||||||
args := make([]interface{}, 3+len(keys))
|
args := make([]interface{}, 3+len(keys))
|
||||||
args[0] = "zunionstore"
|
args[0] = "zunionstore"
|
||||||
args[1] = dest
|
args[1] = dest
|
||||||
args[2] = strconv.Itoa(len(keys))
|
args[2] = len(keys)
|
||||||
for i, key := range keys {
|
for i, key := range keys {
|
||||||
args[3+i] = key
|
args[3+i] = key
|
||||||
}
|
}
|
||||||
|
@ -1755,7 +1754,7 @@ func (c *cmdable) Eval(script string, keys []string, args ...interface{}) *Cmd {
|
||||||
cmdArgs := make([]interface{}, 3+len(keys)+len(args))
|
cmdArgs := make([]interface{}, 3+len(keys)+len(args))
|
||||||
cmdArgs[0] = "eval"
|
cmdArgs[0] = "eval"
|
||||||
cmdArgs[1] = script
|
cmdArgs[1] = script
|
||||||
cmdArgs[2] = strconv.Itoa(len(keys))
|
cmdArgs[2] = len(keys)
|
||||||
for i, key := range keys {
|
for i, key := range keys {
|
||||||
cmdArgs[3+i] = key
|
cmdArgs[3+i] = key
|
||||||
}
|
}
|
||||||
|
@ -1772,7 +1771,7 @@ func (c *cmdable) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
|
||||||
cmdArgs := make([]interface{}, 3+len(keys)+len(args))
|
cmdArgs := make([]interface{}, 3+len(keys)+len(args))
|
||||||
cmdArgs[0] = "evalsha"
|
cmdArgs[0] = "evalsha"
|
||||||
cmdArgs[1] = sha1
|
cmdArgs[1] = sha1
|
||||||
cmdArgs[2] = strconv.Itoa(len(keys))
|
cmdArgs[2] = len(keys)
|
||||||
for i, key := range keys {
|
for i, key := range keys {
|
||||||
cmdArgs[3+i] = key
|
cmdArgs[3+i] = key
|
||||||
}
|
}
|
||||||
|
@ -1984,7 +1983,7 @@ func (c *cmdable) ClusterAddSlots(slots ...int) *StatusCmd {
|
||||||
args[0] = "cluster"
|
args[0] = "cluster"
|
||||||
args[1] = "addslots"
|
args[1] = "addslots"
|
||||||
for i, num := range slots {
|
for i, num := range slots {
|
||||||
args[2+i] = strconv.Itoa(num)
|
args[2+i] = num
|
||||||
}
|
}
|
||||||
cmd := NewStatusCmd(args...)
|
cmd := NewStatusCmd(args...)
|
||||||
c.process(cmd)
|
c.process(cmd)
|
||||||
|
|
Loading…
Reference in New Issue