@@ -9,18 +9,11 @@ import (
99 "github.com/go-redis/redis/v8/internal"
1010)
1111
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
2417
2518func usePrecise (dur time.Duration ) bool {
2619 return dur < time .Second || dur % time .Second != 0
@@ -722,9 +715,7 @@ func (c cmdable) GetSet(ctx context.Context, key string, value interface{}) *Str
722715}
723716
724717// 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).
728719func (c cmdable ) GetEX (ctx context.Context , key string , expiration time.Duration ) * StringCmd {
729720 args := make ([]interface {}, 0 , 4 )
730721 args = append (args , "getex" , key )
@@ -734,7 +725,7 @@ func (c cmdable) GetEX(ctx context.Context, key string, expiration time.Duration
734725 } else {
735726 args = append (args , "ex" , formatSec (ctx , expiration ))
736727 }
737- } else if expiration == Persist {
728+ } else if expiration == 0 {
738729 args = append (args , "persist" )
739730 }
740731
@@ -1222,6 +1213,7 @@ func (c cmdable) HVals(ctx context.Context, key string) *StringSliceCmd {
12221213 return cmd
12231214}
12241215
1216+ // redis-server version >= 6.2.0.
12251217func (c cmdable ) HRandField (ctx context.Context , key string , count int , withValues bool ) * StringSliceCmd {
12261218 args := make ([]interface {}, 0 , 4 )
12271219
@@ -2310,8 +2302,11 @@ func (c cmdable) ZUnionStore(ctx context.Context, dest string, store *ZStore) *I
23102302 return cmd
23112303}
23122304
2305+ // redis-server version >= 6.2.0.
23132306func (c cmdable ) ZRandMember (ctx context.Context , key string , count int , withScores bool ) * StringSliceCmd {
23142307 args := make ([]interface {}, 0 , 4 )
2308+
2309+ // Although count=0 is meaningless, redis accepts count=0.
23152310 args = append (args , "zrandmember" , key , count )
23162311 if withScores {
23172312 args = append (args , "withscores" )
0 commit comments