Dynamics of acquired immunity boosted by exposure to infection