UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'NKzX2Fkiomxmt+tBOiaKN4UDPMN5CBEEZ+YvThwMbzg=' 
WHERE 
  key_id = '50d586e73ce4475ccd0340ea17fa471cfb1c0301884cbcc1c75032696b8706d1' 
  AND (
    token = 'NKzX2Fkiomxmt+tBOiaKN4UDPMN5CBEEZ+YvThwMbzg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00045