UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KlHiwPeZQUivzG1zAWi4Lhw8LuUsFwyuetc+8Q1eb+g=' 
WHERE 
  key_id = '8bc5e097a7e54e8beb06e76b92570ec826fda7f087437d27cdb67244c9facf24' 
  AND (
    token = 'KlHiwPeZQUivzG1zAWi4Lhw8LuUsFwyuetc+8Q1eb+g=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037