UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Bgto0H+De0S/PT2dkldxcItM8yGDd3algGN30NJyMJc=' 
WHERE 
  key_id = '277e62aa65d9a86900442e81130f40c48ad057a500803fe2b3fc4595a2427f59' 
  AND (
    token = 'Bgto0H+De0S/PT2dkldxcItM8yGDd3algGN30NJyMJc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00041