Optimal storage of a single photon by a single intra-cavity atom