From 0358ca4bfeb8022e11cf0ade3a791749b79f840a Mon Sep 17 00:00:00 2001 From: monkey92t Date: Thu, 29 Dec 2022 17:04:57 +0800 Subject: [PATCH 1/5] fix: hook.process.fn should return error instead of cmd.SetErr() Signed-off-by: monkey92t --- .gitignore | 2 +- cluster_commands.go | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index b975a7b..dc322f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *.rdb -testdata/*/ +testdata/* .idea/ diff --git a/cluster_commands.go b/cluster_commands.go index 085bce8..4406223 100644 --- a/cluster_commands.go +++ b/cluster_commands.go @@ -18,11 +18,12 @@ func (c *ClusterClient) DBSize(ctx context.Context) *IntCmd { atomic.AddInt64(&size, n) return nil }) + if err != nil { - cmd.SetErr(err) - } else { - cmd.val = size + return err } + + cmd.val = size return nil }) return cmd @@ -46,10 +47,8 @@ func (c *ClusterClient) ScriptLoad(ctx context.Context, script string) *StringCm return nil }) - if err != nil { - cmd.SetErr(err) - } - return nil + + return err }) return cmd } @@ -60,10 +59,8 @@ func (c *ClusterClient) ScriptFlush(ctx context.Context) *StatusCmd { err := c.ForEachShard(ctx, func(ctx context.Context, shard *Client) error { return shard.ScriptFlush(ctx).Err() }) - if err != nil { - cmd.SetErr(err) - } - return nil + + return err }) return cmd } @@ -98,11 +95,12 @@ func (c *ClusterClient) ScriptExists(ctx context.Context, hashes ...string) *Boo return nil }) + if err != nil { - cmd.SetErr(err) - } else { - cmd.val = result + return err } + + cmd.val = result return nil }) return cmd From 0a57079ece42360e78584f06c8eece6276a566f8 Mon Sep 17 00:00:00 2001 From: monkey92t Date: Thu, 5 Jan 2023 19:14:20 +0800 Subject: [PATCH 2/5] feat: v8 remove redis7 command Signed-off-by: monkey92t --- commands.go | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/commands.go b/commands.go index bbfe089..0ee53b3 100644 --- a/commands.go +++ b/commands.go @@ -13,7 +13,7 @@ import ( // otherwise you will receive an error: (error) ERR syntax error. // For example: // -// rdb.Set(ctx, key, value, redis.KeepTTL) +// rdb.Set(ctx, key, value, redis.KeepTTL) const KeepTTL = -1 func usePrecise(dur time.Duration) bool { @@ -96,10 +96,6 @@ type Cmdable interface { Exists(ctx context.Context, keys ...string) *IntCmd Expire(ctx context.Context, key string, expiration time.Duration) *BoolCmd ExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd - ExpireNX(ctx context.Context, key string, expiration time.Duration) *BoolCmd - ExpireXX(ctx context.Context, key string, expiration time.Duration) *BoolCmd - ExpireGT(ctx context.Context, key string, expiration time.Duration) *BoolCmd - ExpireLT(ctx context.Context, key string, expiration time.Duration) *BoolCmd Keys(ctx context.Context, pattern string) *StringSliceCmd Migrate(ctx context.Context, host, port, key string, db int, timeout time.Duration) *StatusCmd Move(ctx context.Context, key string, db int) *BoolCmd @@ -534,22 +530,6 @@ func (c cmdable) Expire(ctx context.Context, key string, expiration time.Duratio return c.expire(ctx, key, expiration, "") } -func (c cmdable) ExpireNX(ctx context.Context, key string, expiration time.Duration) *BoolCmd { - return c.expire(ctx, key, expiration, "NX") -} - -func (c cmdable) ExpireXX(ctx context.Context, key string, expiration time.Duration) *BoolCmd { - return c.expire(ctx, key, expiration, "XX") -} - -func (c cmdable) ExpireGT(ctx context.Context, key string, expiration time.Duration) *BoolCmd { - return c.expire(ctx, key, expiration, "GT") -} - -func (c cmdable) ExpireLT(ctx context.Context, key string, expiration time.Duration) *BoolCmd { - return c.expire(ctx, key, expiration, "LT") -} - func (c cmdable) expire( ctx context.Context, key string, expiration time.Duration, mode string, ) *BoolCmd { @@ -2049,8 +2029,10 @@ func xClaimArgs(a *XClaimArgs) []interface{} { // xTrim If approx is true, add the "~" parameter, otherwise it is the default "=" (redis default). // example: -// XTRIM key MAXLEN/MINID threshold LIMIT limit. -// XTRIM key MAXLEN/MINID ~ threshold LIMIT limit. +// +// XTRIM key MAXLEN/MINID threshold LIMIT limit. +// XTRIM key MAXLEN/MINID ~ threshold LIMIT limit. +// // The redis-server version is lower than 6.2, please set limit to 0. func (c cmdable) xTrim( ctx context.Context, key, strategy string, @@ -2298,6 +2280,7 @@ func (c cmdable) ZAddXX(ctx context.Context, key string, members ...*Z) *IntCmd // ZAddCh Redis `ZADD key CH score member [score member ...]` command. // Deprecated: Use +// // client.ZAddArgs(ctx, ZAddArgs{ // Ch: true, // Members: []Z, @@ -2311,6 +2294,7 @@ func (c cmdable) ZAddCh(ctx context.Context, key string, members ...*Z) *IntCmd // ZAddNXCh Redis `ZADD key NX CH score member [score member ...]` command. // Deprecated: Use +// // client.ZAddArgs(ctx, ZAddArgs{ // NX: true, // Ch: true, @@ -2326,6 +2310,7 @@ func (c cmdable) ZAddNXCh(ctx context.Context, key string, members ...*Z) *IntCm // ZAddXXCh Redis `ZADD key XX CH score member [score member ...]` command. // Deprecated: Use +// // client.ZAddArgs(ctx, ZAddArgs{ // XX: true, // Ch: true, @@ -2341,6 +2326,7 @@ func (c cmdable) ZAddXXCh(ctx context.Context, key string, members ...*Z) *IntCm // ZIncr Redis `ZADD key INCR score member` command. // Deprecated: Use +// // client.ZAddArgsIncr(ctx, ZAddArgs{ // Members: []Z, // }) @@ -2353,6 +2339,7 @@ func (c cmdable) ZIncr(ctx context.Context, key string, member *Z) *FloatCmd { // ZIncrNX Redis `ZADD key NX INCR score member` command. // Deprecated: Use +// // client.ZAddArgsIncr(ctx, ZAddArgs{ // NX: true, // Members: []Z, @@ -2367,6 +2354,7 @@ func (c cmdable) ZIncrNX(ctx context.Context, key string, member *Z) *FloatCmd { // ZIncrXX Redis `ZADD key XX INCR score member` command. // Deprecated: Use +// // client.ZAddArgsIncr(ctx, ZAddArgs{ // XX: true, // Members: []Z, @@ -2488,11 +2476,13 @@ func (c cmdable) ZPopMin(ctx context.Context, key string, count ...int64) *ZSlic // ZRangeArgs is all the options of the ZRange command. // In version> 6.2.0, you can replace the(cmd): -// ZREVRANGE, -// ZRANGEBYSCORE, -// ZREVRANGEBYSCORE, -// ZRANGEBYLEX, -// ZREVRANGEBYLEX. +// +// ZREVRANGE, +// ZRANGEBYSCORE, +// ZREVRANGEBYSCORE, +// ZRANGEBYLEX, +// ZREVRANGEBYLEX. +// // Please pay attention to your redis-server version. // // Rev, ByScore, ByLex and Offset+Count options require redis-server 6.2.0 and higher. @@ -2897,7 +2887,7 @@ func (c cmdable) ClientKill(ctx context.Context, ipPort string) *StatusCmd { // ClientKillByFilter is new style syntax, while the ClientKill is old // -// CLIENT KILL