MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / cmdSETEXAT

Function cmdSETEXAT

strings.go:704–729  ·  view source on GitHub ↗
(m uhaha.Machine, args []string)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected