|
@@ -250,15 +250,15 @@ func (s *Redis) Eval(script string, keys []string, args ...interface{}) (val int
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// Eval is the implementation of redis eval command.
|
|
|
-func (s *Redis) EvalSha(script string, keys []string, args ...interface{}) (val interface{}, err error) {
|
|
|
+// EvalSha is the implementation of redis evalsha command.
|
|
|
+func (s *Redis) EvalSha(sha string, keys []string, args ...interface{}) (val interface{}, err error) {
|
|
|
err = s.brk.DoWithAcceptable(func() error {
|
|
|
conn, err := getRedis(s)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- val, err = conn.EvalSha(script, keys, args...).Result()
|
|
|
+ val, err = conn.EvalSha(sha, keys, args...).Result()
|
|
|
return err
|
|
|
}, acceptable)
|
|
|
|
|
@@ -1047,6 +1047,16 @@ func (s *Redis) Scard(key string) (val int64, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// ScriptLoad is the implementation of redis script load command.
|
|
|
+func (s *Redis) ScriptLoad(script string) (string, error) {
|
|
|
+ conn, err := getRedis(s)
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+
|
|
|
+ return conn.ScriptLoad(script).Result()
|
|
|
+}
|
|
|
+
|
|
|
// Set is the implementation of redis set command.
|
|
|
func (s *Redis) Set(key string, value string) error {
|
|
|
return s.brk.DoWithAcceptable(func() error {
|
|
@@ -1116,71 +1126,76 @@ func (s *Redis) Sismember(key string, value interface{}) (val bool, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// Srem is the implementation of redis srem command.
|
|
|
-func (s *Redis) Srem(key string, values ...interface{}) (val int, err error) {
|
|
|
+// Smembers is the implementation of redis smembers command.
|
|
|
+func (s *Redis) Smembers(key string) (val []string, err error) {
|
|
|
err = s.brk.DoWithAcceptable(func() error {
|
|
|
conn, err := getRedis(s)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- v, err := conn.SRem(key, values...).Result()
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- val = int(v)
|
|
|
- return nil
|
|
|
+ val, err = conn.SMembers(key).Result()
|
|
|
+ return err
|
|
|
}, acceptable)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// Smembers is the implementation of redis smembers command.
|
|
|
-func (s *Redis) Smembers(key string) (val []string, err error) {
|
|
|
+// Spop is the implementation of redis spop command.
|
|
|
+func (s *Redis) Spop(key string) (val string, err error) {
|
|
|
err = s.brk.DoWithAcceptable(func() error {
|
|
|
conn, err := getRedis(s)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- val, err = conn.SMembers(key).Result()
|
|
|
+ val, err = conn.SPop(key).Result()
|
|
|
return err
|
|
|
}, acceptable)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// Spop is the implementation of redis spop command.
|
|
|
-func (s *Redis) Spop(key string) (val string, err error) {
|
|
|
+// Srandmember is the implementation of redis srandmember command.
|
|
|
+func (s *Redis) Srandmember(key string, count int) (val []string, err error) {
|
|
|
err = s.brk.DoWithAcceptable(func() error {
|
|
|
conn, err := getRedis(s)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- val, err = conn.SPop(key).Result()
|
|
|
+ val, err = conn.SRandMemberN(key, int64(count)).Result()
|
|
|
return err
|
|
|
}, acceptable)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// Srandmember is the implementation of redis srandmember command.
|
|
|
-func (s *Redis) Srandmember(key string, count int) (val []string, err error) {
|
|
|
+// Srem is the implementation of redis srem command.
|
|
|
+func (s *Redis) Srem(key string, values ...interface{}) (val int, err error) {
|
|
|
err = s.brk.DoWithAcceptable(func() error {
|
|
|
conn, err := getRedis(s)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- val, err = conn.SRandMemberN(key, int64(count)).Result()
|
|
|
- return err
|
|
|
+ v, err := conn.SRem(key, values...).Result()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ val = int(v)
|
|
|
+ return nil
|
|
|
}, acceptable)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// String returns the string representation of s.
|
|
|
+func (s *Redis) String() string {
|
|
|
+ return s.Addr
|
|
|
+}
|
|
|
+
|
|
|
// Sunion is the implementation of redis sunion command.
|
|
|
func (s *Redis) Sunion(keys ...string) (val []string, err error) {
|
|
|
err = s.brk.DoWithAcceptable(func() error {
|
|
@@ -1682,20 +1697,6 @@ func (s *Redis) Zunionstore(dest string, store ZStore, keys ...string) (val int6
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// String returns the string representation of s.
|
|
|
-func (s *Redis) String() string {
|
|
|
- return s.Addr
|
|
|
-}
|
|
|
-
|
|
|
-func (s *Redis) ScriptLoad(script string) (string, error) {
|
|
|
- conn, err := getRedis(s)
|
|
|
- if err != nil {
|
|
|
- return "", err
|
|
|
- }
|
|
|
-
|
|
|
- return conn.ScriptLoad(script).Result()
|
|
|
-}
|
|
|
-
|
|
|
func acceptable(err error) bool {
|
|
|
return err == nil || err == red.Nil
|
|
|
}
|