(m uhaha.Machine, args []string)
| 702 | if err != nil { |
| 703 | return nil, fmt.Errorf("ERR value is not an integer or out of range") |
| 704 | } |
| 705 | if n <= 0 { |
| 706 | return nil, fmt.Errorf("ERR invalid expire time in 'set' command") |
| 707 | } |
| 708 | if strings.EqualFold(args[i], "EX") { |
| 709 | exSeconds = n |
| 710 | } else { |
| 711 | pxMilliseconds = n |
| 712 | } |
| 713 | i++ |
| 714 | default: |
| 715 | return nil, fmt.Errorf("ERR syntax error") |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | // Contradictory options are a syntax error, as in Redis. |
| 720 | if (nx && xx) || (keepttl && (exSeconds > 0 || pxMilliseconds > 0)) || (exSeconds > 0 && pxMilliseconds > 0) { |
| 721 | return nil, fmt.Errorf("ERR syntax error") |
| 722 | } |
| 723 | |
| 724 | exists, err := ldb.Exists(key) |
| 725 | if err != nil { |
| 726 | return nil, err |
| 727 | } |
| 728 | if (nx && exists > 0) || (xx && exists == 0) { |
| 729 | // Redis answers a null bulk when the NX/XX condition is not met. |
| 730 | return nil, nil |
| 731 | } |
| 732 |
nothing calls this directly
no outgoing calls
no test coverage detected