Skip to content

Commit 960e4d6

Browse files
authored
Explain the use restrictions of KeepTTL. (#1799)
Signed-off-by: monkey92t <[email protected]>
1 parent f0b2f90 commit 960e4d6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

commands.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
)
1111

1212
// KeepTTL is an option for Set command to keep key's existing TTL.
13+
// It requires your redis-server version >= 6.0 (Otherwise you will receive an error: (error) ERR syntax error).
1314
// For example:
1415
//
1516
// rdb.Set(ctx, key, value, redis.KeepTTL)
@@ -841,6 +842,7 @@ func (c cmdable) MSetNX(ctx context.Context, values ...interface{}) *BoolCmd {
841842
//
842843
// Zero expiration means the key has no expiration time.
843844
// KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.
845+
// It requires your redis-server version >= 6.0 (Otherwise you will receive an error: (error) ERR syntax error).
844846
func (c cmdable) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd {
845847
args := make([]interface{}, 3, 5)
846848
args[0] = "set"
@@ -874,6 +876,7 @@ type SetArgs struct {
874876
Get bool
875877

876878
// KeepTTL is a Redis KEEPTTL option to keep existing TTL.
879+
// It requires your redis-server version >= 6.0 (Otherwise you will receive an error: (error) ERR syntax error).
877880
KeepTTL bool
878881
}
879882

@@ -922,6 +925,7 @@ func (c cmdable) SetEX(ctx context.Context, key string, value interface{}, expir
922925
//
923926
// Zero expiration means the key has no expiration time.
924927
// KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.
928+
// It requires your redis-server version >= 6.0 (Otherwise you will receive an error: (error) ERR syntax error).
925929
func (c cmdable) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd {
926930
var cmd *BoolCmd
927931
switch expiration {
@@ -946,6 +950,7 @@ func (c cmdable) SetNX(ctx context.Context, key string, value interface{}, expir
946950
//
947951
// Zero expiration means the key has no expiration time.
948952
// KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.
953+
// It requires your redis-server version >= 6.0 (Otherwise you will receive an error: (error) ERR syntax error).
949954
func (c cmdable) SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd {
950955
var cmd *BoolCmd
951956
switch expiration {

0 commit comments

Comments
 (0)