@@ -32,37 +32,43 @@ type StringCmdable interface {
3232
3333func (c cmdable ) Append (ctx context.Context , key , value string ) * IntCmd {
3434 cmd := NewIntCmd (ctx , "append" , key , value )
35+ cmd .keys = append (cmd .keys , key )
3536 _ = c (ctx , cmd )
3637 return cmd
3738}
3839
3940func (c cmdable ) Decr (ctx context.Context , key string ) * IntCmd {
4041 cmd := NewIntCmd (ctx , "decr" , key )
42+ cmd .keys = append (cmd .keys , key )
4143 _ = c (ctx , cmd )
4244 return cmd
4345}
4446
4547func (c cmdable ) DecrBy (ctx context.Context , key string , decrement int64 ) * IntCmd {
4648 cmd := NewIntCmd (ctx , "decrby" , key , decrement )
49+ cmd .keys = append (cmd .keys , key )
4750 _ = c (ctx , cmd )
4851 return cmd
4952}
5053
5154// Get Redis `GET key` command. It returns redis.Nil error when key does not exist.
5255func (c cmdable ) Get (ctx context.Context , key string ) * StringCmd {
5356 cmd := NewStringCmd (ctx , "get" , key )
57+ cmd .keys = append (cmd .keys , key )
5458 _ = c (ctx , cmd )
5559 return cmd
5660}
5761
5862func (c cmdable ) GetRange (ctx context.Context , key string , start , end int64 ) * StringCmd {
5963 cmd := NewStringCmd (ctx , "getrange" , key , start , end )
64+ cmd .keys = append (cmd .keys , key )
6065 _ = c (ctx , cmd )
6166 return cmd
6267}
6368
6469func (c cmdable ) GetSet (ctx context.Context , key string , value interface {}) * StringCmd {
6570 cmd := NewStringCmd (ctx , "getset" , key , value )
71+ cmd .keys = append (cmd .keys , key )
6672 _ = c (ctx , cmd )
6773 return cmd
6874}
@@ -83,31 +89,36 @@ func (c cmdable) GetEx(ctx context.Context, key string, expiration time.Duration
8389 }
8490
8591 cmd := NewStringCmd (ctx , args ... )
92+ cmd .keys = append (cmd .keys , key )
8693 _ = c (ctx , cmd )
8794 return cmd
8895}
8996
9097// GetDel redis-server version >= 6.2.0.
9198func (c cmdable ) GetDel (ctx context.Context , key string ) * StringCmd {
9299 cmd := NewStringCmd (ctx , "getdel" , key )
100+ cmd .keys = append (cmd .keys , key )
93101 _ = c (ctx , cmd )
94102 return cmd
95103}
96104
97105func (c cmdable ) Incr (ctx context.Context , key string ) * IntCmd {
98106 cmd := NewIntCmd (ctx , "incr" , key )
107+ cmd .keys = append (cmd .keys , key )
99108 _ = c (ctx , cmd )
100109 return cmd
101110}
102111
103112func (c cmdable ) IncrBy (ctx context.Context , key string , value int64 ) * IntCmd {
104113 cmd := NewIntCmd (ctx , "incrby" , key , value )
114+ cmd .keys = append (cmd .keys , key )
105115 _ = c (ctx , cmd )
106116 return cmd
107117}
108118
109119func (c cmdable ) IncrByFloat (ctx context.Context , key string , value float64 ) * FloatCmd {
110120 cmd := NewFloatCmd (ctx , "incrbyfloat" , key , value )
121+ cmd .keys = append (cmd .keys , key )
111122 _ = c (ctx , cmd )
112123 return cmd
113124}
@@ -125,6 +136,7 @@ func (c cmdable) MGet(ctx context.Context, keys ...string) *SliceCmd {
125136 args [1 + i ] = key
126137 }
127138 cmd := NewSliceCmd (ctx , args ... )
139+ cmd .keys = append (cmd .keys , keys ... )
128140 _ = c (ctx , cmd )
129141 return cmd
130142}
@@ -139,6 +151,7 @@ func (c cmdable) MSet(ctx context.Context, values ...interface{}) *StatusCmd {
139151 args [0 ] = "mset"
140152 args = appendArgs (args , values )
141153 cmd := NewStatusCmd (ctx , args ... )
154+ // cmd.keys = append(cmd.keys, keys...)
142155 _ = c (ctx , cmd )
143156 return cmd
144157}
@@ -153,6 +166,7 @@ func (c cmdable) MSetNX(ctx context.Context, values ...interface{}) *BoolCmd {
153166 args [0 ] = "msetnx"
154167 args = appendArgs (args , values )
155168 cmd := NewBoolCmd (ctx , args ... )
169+ // cmd.keys = append(cmd.keys, keys...)
156170 _ = c (ctx , cmd )
157171 return cmd
158172}
@@ -179,6 +193,7 @@ func (c cmdable) Set(ctx context.Context, key string, value interface{}, expirat
179193 }
180194
181195 cmd := NewStatusCmd (ctx , args ... )
196+ cmd .keys = append (cmd .keys , key )
182197 _ = c (ctx , cmd )
183198 return cmd
184199}
@@ -230,13 +245,15 @@ func (c cmdable) SetArgs(ctx context.Context, key string, value interface{}, a S
230245 }
231246
232247 cmd := NewStatusCmd (ctx , args ... )
248+ cmd .keys = append (cmd .keys , key )
233249 _ = c (ctx , cmd )
234250 return cmd
235251}
236252
237253// SetEx Redis `SETEx key expiration value` command.
238254func (c cmdable ) SetEx (ctx context.Context , key string , value interface {}, expiration time.Duration ) * StatusCmd {
239255 cmd := NewStatusCmd (ctx , "setex" , key , formatSec (ctx , expiration ), value )
256+ cmd .keys = append (cmd .keys , key )
240257 _ = c (ctx , cmd )
241258 return cmd
242259}
@@ -261,7 +278,7 @@ func (c cmdable) SetNX(ctx context.Context, key string, value interface{}, expir
261278 cmd = NewBoolCmd (ctx , "set" , key , value , "ex" , formatSec (ctx , expiration ), "nx" )
262279 }
263280 }
264-
281+ cmd . keys = append ( cmd . keys , key )
265282 _ = c (ctx , cmd )
266283 return cmd
267284}
@@ -285,19 +302,21 @@ func (c cmdable) SetXX(ctx context.Context, key string, value interface{}, expir
285302 cmd = NewBoolCmd (ctx , "set" , key , value , "ex" , formatSec (ctx , expiration ), "xx" )
286303 }
287304 }
288-
305+ cmd . keys = append ( cmd . keys , key )
289306 _ = c (ctx , cmd )
290307 return cmd
291308}
292309
293310func (c cmdable ) SetRange (ctx context.Context , key string , offset int64 , value string ) * IntCmd {
294311 cmd := NewIntCmd (ctx , "setrange" , key , offset , value )
312+ cmd .keys = append (cmd .keys , key )
295313 _ = c (ctx , cmd )
296314 return cmd
297315}
298316
299317func (c cmdable ) StrLen (ctx context.Context , key string ) * IntCmd {
300318 cmd := NewIntCmd (ctx , "strlen" , key )
319+ cmd .keys = append (cmd .keys , key )
301320 _ = c (ctx , cmd )
302321 return cmd
303322}
0 commit comments