mirror of
https://github.com/redis/go-redis.git
synced 2025-04-17 20:17:02 +03:00
Script: Fix Exists
to use hash instead of source (#726)
`SCRIPT EXISTS` accepts a hash, not the raw source: https://redis.io/commands/script-exists
This commit is contained in:
parent
d0a2b8bdf3
commit
7acec74c59
10
commands.go
10
commands.go
@ -214,7 +214,7 @@ type Cmdable interface {
|
|||||||
Time() *TimeCmd
|
Time() *TimeCmd
|
||||||
Eval(script string, keys []string, args ...interface{}) *Cmd
|
Eval(script string, keys []string, args ...interface{}) *Cmd
|
||||||
EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
|
EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
|
||||||
ScriptExists(scripts ...string) *BoolSliceCmd
|
ScriptExists(hashes ...string) *BoolSliceCmd
|
||||||
ScriptFlush() *StatusCmd
|
ScriptFlush() *StatusCmd
|
||||||
ScriptKill() *StatusCmd
|
ScriptKill() *StatusCmd
|
||||||
ScriptLoad(script string) *StringCmd
|
ScriptLoad(script string) *StringCmd
|
||||||
@ -1884,12 +1884,12 @@ func (c *cmdable) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
|
|||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmdable) ScriptExists(scripts ...string) *BoolSliceCmd {
|
func (c *cmdable) ScriptExists(hashes ...string) *BoolSliceCmd {
|
||||||
args := make([]interface{}, 2+len(scripts))
|
args := make([]interface{}, 2+len(hashes))
|
||||||
args[0] = "script"
|
args[0] = "script"
|
||||||
args[1] = "exists"
|
args[1] = "exists"
|
||||||
for i, script := range scripts {
|
for i, hash := range hashes {
|
||||||
args[2+i] = script
|
args[2+i] = hash
|
||||||
}
|
}
|
||||||
cmd := NewBoolSliceCmd(args...)
|
cmd := NewBoolSliceCmd(args...)
|
||||||
c.process(cmd)
|
c.process(cmd)
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
type scripter interface {
|
type scripter interface {
|
||||||
Eval(script string, keys []string, args ...interface{}) *Cmd
|
Eval(script string, keys []string, args ...interface{}) *Cmd
|
||||||
EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
|
EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
|
||||||
ScriptExists(scripts ...string) *BoolSliceCmd
|
ScriptExists(hashes ...string) *BoolSliceCmd
|
||||||
ScriptLoad(script string) *StringCmd
|
ScriptLoad(script string) *StringCmd
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ func (s *Script) Load(c scripter) *StringCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Script) Exists(c scripter) *BoolSliceCmd {
|
func (s *Script) Exists(c scripter) *BoolSliceCmd {
|
||||||
return c.ScriptExists(s.src)
|
return c.ScriptExists(s.hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Script) Eval(c scripter, keys []string, args ...interface{}) *Cmd {
|
func (s *Script) Eval(c scripter, keys []string, args ...interface{}) *Cmd {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user