UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ic6cjWxO9CCNyrfowL+Rf2mrt48XVoX1A+JOI4+ygWo=' 
WHERE 
  key_id = 'bd57422db85a55c945823780d38584132c797d822935f448930c83bc1a9b1d3e' 
  AND (
    token = 'ic6cjWxO9CCNyrfowL+Rf2mrt48XVoX1A+JOI4+ygWo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00061