UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'OOO2+IMHWx0Q0ZSal96rFcBBrMdJ74Gw1bWfwOQvSXk=' 
WHERE 
  key_id = '87cd892bc0d754387b0f3e43c69af6110cad1675a6ce7e62ed68b366d961181f' 
  AND (
    token = 'OOO2+IMHWx0Q0ZSal96rFcBBrMdJ74Gw1bWfwOQvSXk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00030