We investigate theoretically the coupling of a cavity mode to a continuous distribution of emitters. We discuss the influence of the emitters inhomogeneous broadening on the existence and on the coherence properties of the polaritonic peaks. We find that their coherence depends crucially on the shape of the distribution and not only on its width. Under certain conditions the coupling to the cavity protects the polaritonic states from inhomogeneous broadening, resulting in a longer storage time for a quantum memory based on emitters ensembles. When two different ensembles of emitters are coupled to the resonator, they support a peculiar collective dark state, also very attractive for the storage of quantum information.