SetIFDNE sets the value only if the current value's digest does NOT equal matchDigest. This is a compare-and-set operation using xxh3 digest for optimistic locking. The matchDigest parameter is a uint64 xxh3 hash value. Returns "OK" on success (digest didn't match, value was set). Returns redis.Ni
(ctx context.Context, key string, value interface{}, matchDigest uint64, expiration time.Duration)
| 852 | // NOTE SetIFDNE is still experimental |
| 853 | // it's signature and behaviour may change |
| 854 | func (c cmdable) SetIFDNE(ctx context.Context, key string, value interface{}, matchDigest uint64, expiration time.Duration) *StatusCmd { |
| 855 | args := []interface{}{"set", key, value} |
| 856 | |
| 857 | if expiration > 0 { |
| 858 | if usePrecise(expiration) { |
| 859 | args = append(args, "px", formatMs(ctx, expiration)) |
| 860 | } else { |
| 861 | args = append(args, "ex", formatSec(ctx, expiration)) |
| 862 | } |
| 863 | } else if expiration == KeepTTL { |
| 864 | args = append(args, "keepttl") |
| 865 | } |
| 866 | |
| 867 | args = append(args, "ifdne", fmt.Sprintf("%016x", matchDigest)) |
| 868 | |
| 869 | cmd := NewStatusCmd(ctx, args...) |
| 870 | _ = c(ctx, cmd) |
| 871 | return cmd |
| 872 | } |
| 873 | |
| 874 | // SetIFDNEGet sets the value only if the current value's digest does NOT equal matchDigest, |
| 875 | // and returns the previous value. |
nothing calls this directly
no test coverage detected