1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-15 12:41:41 +03:00

Tweak API

This commit is contained in:
Vladimir Mihailenco
2021-02-17 15:12:10 +02:00
parent 7b7f9d6e0e
commit 61680f373c
4 changed files with 35 additions and 28 deletions

View File

@ -807,16 +807,17 @@ type SetArgs struct {
// SetArgs supports all the options that the SET command supports.
// It is the alternative to the Set function when you want
// to have more control over the options.
func (c cmdable) SetArgs(ctx context.Context, key string, value interface{}, a *SetArgs) *StatusCmd {
func (c cmdable) SetArgs(ctx context.Context, key string, value interface{}, a SetArgs) *StatusCmd {
args := []interface{}{"set", key, value}
if a.KeepTTL {
args = append(args, "keepttl")
}
if !a.ExpireAt.IsZero() && !a.KeepTTL {
if !a.ExpireAt.IsZero() {
args = append(args, "exat", a.ExpireAt.Unix())
} else if a.TTL > 0 && !a.KeepTTL {
}
if a.TTL > 0 {
if usePrecise(a.TTL) {
args = append(args, "px", formatMs(ctx, a.TTL))
} else {