From 7acec74c599074e0a8e21e1b6aeb6ee80f442ab4 Mon Sep 17 00:00:00 2001 From: Evan Goldschmidt Date: Mon, 5 Mar 2018 00:54:11 -0800 Subject: [PATCH] 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 --- commands.go | 10 +++++----- script.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/commands.go b/commands.go index 175cd851..6609a74f 100644 --- a/commands.go +++ b/commands.go @@ -214,7 +214,7 @@ type Cmdable interface { Time() *TimeCmd Eval(script string, keys []string, args ...interface{}) *Cmd EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd - ScriptExists(scripts ...string) *BoolSliceCmd + ScriptExists(hashes ...string) *BoolSliceCmd ScriptFlush() *StatusCmd ScriptKill() *StatusCmd ScriptLoad(script string) *StringCmd @@ -1884,12 +1884,12 @@ func (c *cmdable) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd return cmd } -func (c *cmdable) ScriptExists(scripts ...string) *BoolSliceCmd { - args := make([]interface{}, 2+len(scripts)) +func (c *cmdable) ScriptExists(hashes ...string) *BoolSliceCmd { + args := make([]interface{}, 2+len(hashes)) args[0] = "script" args[1] = "exists" - for i, script := range scripts { - args[2+i] = script + for i, hash := range hashes { + args[2+i] = hash } cmd := NewBoolSliceCmd(args...) c.process(cmd) diff --git a/script.go b/script.go index 74135f5a..09f36d93 100644 --- a/script.go +++ b/script.go @@ -10,7 +10,7 @@ import ( type scripter interface { Eval(script 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 } @@ -40,7 +40,7 @@ func (s *Script) Load(c scripter) *StringCmd { } 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 {