@@ -9,18 +9,11 @@ import (
9
9
"github.com/go-redis/redis/v8/internal"
10
10
)
11
11
12
- const (
13
- // KeepTTL is an option for Set command to keep key's existing TTL.
14
- // For example:
15
- //
16
- // rdb.Set(ctx, key, value, redis.KeepTTL)
17
- KeepTTL = - 1
18
-
19
- // Persist is remove the time to live associated with the key.
20
- // For example:
21
- // rdb.GetEX(ctx, key, redis.Persist)
22
- Persist = - 2
23
- )
12
+ // KeepTTL is an option for Set command to keep key's existing TTL.
13
+ // For example:
14
+ //
15
+ // rdb.Set(ctx, key, value, redis.KeepTTL)
16
+ const KeepTTL = - 1
24
17
25
18
func usePrecise (dur time.Duration ) bool {
26
19
return dur < time .Second || dur % time .Second != 0
@@ -722,9 +715,7 @@ func (c cmdable) GetSet(ctx context.Context, key string, value interface{}) *Str
722
715
}
723
716
724
717
// redis-server version >= 6.2.0.
725
- //
726
- // A value of zero means that the expiration time will not be changed.
727
- // Persist(-2) Remove the time to live associated with the key.
718
+ // A expiration of zero remove the time to live associated with the key(GetEX key persist).
728
719
func (c cmdable ) GetEX (ctx context.Context , key string , expiration time.Duration ) * StringCmd {
729
720
args := make ([]interface {}, 0 , 4 )
730
721
args = append (args , "getex" , key )
@@ -734,7 +725,7 @@ func (c cmdable) GetEX(ctx context.Context, key string, expiration time.Duration
734
725
} else {
735
726
args = append (args , "ex" , formatSec (ctx , expiration ))
736
727
}
737
- } else if expiration == Persist {
728
+ } else if expiration == 0 {
738
729
args = append (args , "persist" )
739
730
}
740
731
@@ -1222,6 +1213,7 @@ func (c cmdable) HVals(ctx context.Context, key string) *StringSliceCmd {
1222
1213
return cmd
1223
1214
}
1224
1215
1216
+ // redis-server version >= 6.2.0.
1225
1217
func (c cmdable ) HRandField (ctx context.Context , key string , count int , withValues bool ) * StringSliceCmd {
1226
1218
args := make ([]interface {}, 0 , 4 )
1227
1219
@@ -2310,8 +2302,11 @@ func (c cmdable) ZUnionStore(ctx context.Context, dest string, store *ZStore) *I
2310
2302
return cmd
2311
2303
}
2312
2304
2305
+ // redis-server version >= 6.2.0.
2313
2306
func (c cmdable ) ZRandMember (ctx context.Context , key string , count int , withScores bool ) * StringSliceCmd {
2314
2307
args := make ([]interface {}, 0 , 4 )
2308
+
2309
+ // Although count=0 is meaningless, redis accepts count=0.
2315
2310
args = append (args , "zrandmember" , key , count )
2316
2311
if withScores {
2317
2312
args = append (args , "withscores" )
0 commit comments