A cell derived from B or T lymphocytes that can quickly recognize a foreign antigen to which the body has been previously exposed. Memory T cells stimulate T helper lymphocytes and cytotoxic T cells; memory B cells stimulate the production of antigen-specific antibodies by B plasma cells. Both types of memory cells survive for years, providing a durable immune response against foreign antigens.