Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain the use restrictions of KeepTTL. #1799

Merged
merged 1 commit into from Jun 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions commands.go
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