Skip to content

Commit

Permalink
Explain the use restrictions of KeepTTL. (redis#1799)
Browse files Browse the repository at this point in the history
Signed-off-by: monkey92t <[email protected]>
  • Loading branch information
monkey92t authored Jun 25, 2021
1 parent f0b2f90 commit 960e4d6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 960e4d6

Please sign in to comment.