Dear student,
If a person is attacked by the antigen for the first time, the memory cells are formed for the antigen. Now when the same antigen attacks the person second time, the memory cells immediately recognise the antigen and takes action against it.
Memory cells are supposed to live up to twenty years in the body.
Regards.