UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'P2hedHnirVaILebGuN03/OCpg4LE7qXDkU59HZXpGSk=' 
WHERE 
  key_id = '24cb014b979769520f8490e19f07c3bead840d1d1d16205656df46df61dcd8ef' 
  AND (
    token = 'P2hedHnirVaILebGuN03/OCpg4LE7qXDkU59HZXpGSk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035