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.
(ctx context.Context, key string, value interface{}, a SetArgs)
| 524 | // It is the alternative to the Set function when you want |
| 525 | // to have more control over the options. |
| 526 | func (c cmdable) SetArgs(ctx context.Context, key string, value interface{}, a SetArgs) *StatusCmd { |
| 527 | args := []interface{}{"set", key, value} |
| 528 | |
| 529 | if a.KeepTTL { |
| 530 | args = append(args, "keepttl") |
| 531 | } |
| 532 | |
| 533 | if !a.ExpireAt.IsZero() { |
| 534 | args = append(args, "exat", a.ExpireAt.Unix()) |
| 535 | } |
| 536 | if a.TTL > 0 { |
| 537 | if usePrecise(a.TTL) { |
| 538 | args = append(args, "px", formatMs(ctx, a.TTL)) |
| 539 | } else { |
| 540 | args = append(args, "ex", formatSec(ctx, a.TTL)) |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | if a.Mode != "" { |
| 545 | args = append(args, a.Mode) |
| 546 | |
| 547 | // Add match value/digest for CAS modes |
| 548 | switch a.Mode { |
| 549 | case "ifeq", "IFEQ", "ifne", "IFNE": |
| 550 | if a.MatchValue != nil { |
| 551 | args = append(args, a.MatchValue) |
| 552 | } |
| 553 | case "ifdeq", "IFDEQ", "ifdne", "IFDNE": |
| 554 | if a.MatchDigest != 0 { |
| 555 | args = append(args, fmt.Sprintf("%016x", a.MatchDigest)) |
| 556 | } |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | if a.Get { |
| 561 | args = append(args, "get") |
| 562 | } |
| 563 | |
| 564 | cmd := NewStatusCmd(ctx, args...) |
| 565 | _ = c(ctx, cmd) |
| 566 | return cmd |
| 567 | } |
| 568 | |
| 569 | // SetEx sets the value and expiration of a key. |
| 570 | // |
nothing calls this directly
no test coverage detected