UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'QqN7QiOnNEqrXncRxQe6uWetZmtcCiRG4l+w+bk9vd4=' 
WHERE 
  key_id = '949996e8638b3582af5218910a49f0fbd78e018bbaeee37d053b8150cc200918' 
  AND (
    token = 'QqN7QiOnNEqrXncRxQe6uWetZmtcCiRG4l+w+bk9vd4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00036