UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'gx4Wx/vEm6fk5Ny9efreJFmRxLgphLEuT49P+C8h6X4=' 
WHERE 
  key_id = '1039a7e7371b3cc7afe38346657f541657af6f433cf7ca95e7cd330863103330' 
  AND (
    token = 'gx4Wx/vEm6fk5Ny9efreJFmRxLgphLEuT49P+C8h6X4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029