UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '3UoHgwiZ4dW0cneMQDzFVBs78HAA2eu1Gd7ula5r698=' 
WHERE 
  key_id = '316b811c053b67de654f97c38887fe96ba64f6f38a7161f797535a816dd2bc34' 
  AND (
    token = '3UoHgwiZ4dW0cneMQDzFVBs78HAA2eu1Gd7ula5r698=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028