Where and how is information about pathogen immunity stored in a cell?
All the body does is produce a ton of cells that can recognize single antigens. Each time you encounter pathogens, some of these naïve cells contact antigen that can activate them. The activated clone replicates itself, forming effector cells that can deal with pathogens. 

As the infection is cleared and the population of effector cells begins to contract (i.e. many die off or become anergic), some of them undergo changes which alter their migratory pattern and longevity. Some can stay in the tissue that was originally infected as tissue-resident memory cells. Some home back to the lymph node and hang there as central memory cells. The lineage is affected largely by chemical signals being produced by the tissue and other immune cells in the vicinity.

Upon re-encounter of the same pathogen, if it has some of the same antigenic determinants as the original infection, these memory cells are already known to be specific to them. Encountering the same antigen will cause these memory cells to undergo another round of clonal expansion, producing more effector cells and additional memory cells so the process can repeat. These events can be limited by telomere length or inhibitory molecules, as a caveat.

The key understanding is that the immunologic memory is actually stored in the repertoire of long-lived memory cells, and in part results from recombination events at the T or B-cell receptor locus during their maturation before they're released as naïve cells.

See: Abbas (2014). Cellular and Molecular Immunology, 8th ED., many different chapters.