UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'uiUgm7GT7u3oXrkKPKzG355lNQ4pIUtXwNndovWsAjk=' 
WHERE 
  key_id = '1f12cc247f30151166da90c71f24116c92e2f43bdec241af45dbee03cb312bb4' 
  AND (
    token = 'uiUgm7GT7u3oXrkKPKzG355lNQ4pIUtXwNndovWsAjk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029