  We theoretically analyse the efficiency of a quantum memory for single
photons. The photons propagate along a transmission line and impinge on one of
the mirrors of a high-finesse cavity. The quantum memory is constituted by a
single atom within the optical resonator. Photon storage is realised by the
controlled transfer of the photonic excitation into a metastable state of the
atom and occurs via a Raman transition with a suitably tailored laser pulse,
which drives the atom. Our study is supported by numerical simulations, in
which we include the modes of the transmission line and we use the experimental
parameters of existing experimental setups. It reproduces the results derived
using input-output theory in the corresponding regime and can be extended to
compute dynamics where the input-output formalism cannot be straightforwardly
applied. Our analysis determines the maximal storage efficiency, namely, the
maximal probability to store the photon in a stable atomic excitation, in the
presence of spontaneous decay and cavity parasitic losses. It further delivers
the form of the laser pulse that achieves the maximal efficiency by partially
compensating parasitic losses. We numerically assess the conditions under which
storage based on adiabatic dynamics is preferable to non-adiabatic pulses.
Moreover, we systematically determine the shortest photon pulse that can be
efficiently stored as a function of the system parameters.
