UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'rDbPwTDx1vJej3JxkrLKvNFWNKSmD+vWdy4CpDPaSoE=' 
WHERE 
  key_id = '804523de05c3569a9a177f5795baf4652e421b6d82c3de53052d2594cfaaa8c2' 
  AND (
    token = 'rDbPwTDx1vJej3JxkrLKvNFWNKSmD+vWdy4CpDPaSoE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00041