From 960e4d6cf0b378c8444714e2110263a720fa90ad Mon Sep 17 00:00:00 2001 From: monkey92t Date: Fri, 25 Jun 2021 11:58:21 +0800 Subject: [PATCH] Explain the use restrictions of KeepTTL. (#1799) Signed-off-by: monkey92t --- commands.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/commands.go b/commands.go index e12fbc5c1..51a4ef847 100644 --- a/commands.go +++ b/commands.go @@ -10,6 +10,7 @@ import ( ) // KeepTTL is an option for Set command to keep key's existing TTL. +// It requires your redis-server version >= 6.0 (Otherwise you will receive an error: (error) ERR syntax error). // For example: // // rdb.Set(ctx, key, value, redis.KeepTTL) @@ -841,6 +842,7 @@ func (c cmdable) MSetNX(ctx context.Context, values ...interface{}) *BoolCmd { // // Zero expiration means the key has no expiration time. // KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL. +// It requires your redis-server version >= 6.0 (Otherwise you will receive an error: (error) ERR syntax error). func (c cmdable) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd { args := make([]interface{}, 3, 5) args[0] = "set" @@ -874,6 +876,7 @@ type SetArgs struct { Get bool // KeepTTL is a Redis KEEPTTL option to keep existing TTL. + // It requires your redis-server version >= 6.0 (Otherwise you will receive an error: (error) ERR syntax error). KeepTTL bool } @@ -922,6 +925,7 @@ func (c cmdable) SetEX(ctx context.Context, key string, value interface{}, expir // // Zero expiration means the key has no expiration time. // KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL. +// It requires your redis-server version >= 6.0 (Otherwise you will receive an error: (error) ERR syntax error). func (c cmdable) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd { var cmd *BoolCmd switch expiration { @@ -946,6 +950,7 @@ func (c cmdable) SetNX(ctx context.Context, key string, value interface{}, expir // // Zero expiration means the key has no expiration time. // KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL. +// It requires your redis-server version >= 6.0 (Otherwise you will receive an error: (error) ERR syntax error). func (c cmdable) SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd { var cmd *BoolCmd switch expiration {