SetIFEQGet Redis `SET key value [expiration] IFEQ match-value GET` command. Compare-and-set with GET: only sets the value if the current value equals matchValue, and returns the previous value. Returns the previous value on success. Returns nil if the operation was aborted due to condition not matc
(ctx context.Context, key string, value interface{}, matchValue interface{}, expiration time.Duration)
| 684 | // NOTE SetIFEQGet is still experimental |
| 685 | // it's signature and behaviour may change |
| 686 | func (c cmdable) SetIFEQGet(ctx context.Context, key string, value interface{}, matchValue interface{}, expiration time.Duration) *StringCmd { |
| 687 | args := []interface{}{"set", key, value} |
| 688 | |
| 689 | if expiration > 0 { |
| 690 | if usePrecise(expiration) { |
| 691 | args = append(args, "px", formatMs(ctx, expiration)) |
| 692 | } else { |
| 693 | args = append(args, "ex", formatSec(ctx, expiration)) |
| 694 | } |
| 695 | } else if expiration == KeepTTL { |
| 696 | args = append(args, "keepttl") |
| 697 | } |
| 698 | |
| 699 | args = append(args, "ifeq", matchValue, "get") |
| 700 | |
| 701 | cmd := NewStringCmd(ctx, args...) |
| 702 | _ = c(ctx, cmd) |
| 703 | return cmd |
| 704 | } |
| 705 | |
| 706 | // SetIFNE Redis `SET key value [expiration] IFNE match-value` command. |
| 707 | // Compare-and-set: only sets the value if the current value does not equal matchValue. |
nothing calls this directly
no test coverage detected