To address the black-box nature and lack of transparency of existing CNN-based image restoration methods, this paper proposes MemoryNet, which combines memory layers of three different granularities with contrastive learning. MemoryNet performs contrastive learning by classifying samples into three categories: positive, negative, and real. The memory layers preserve the deep features of the image, while contrastive learning balances the learned features. Experimental results on Derain, Deshadow, and Deblur tasks demonstrate the effectiveness of the proposed method in improving restoration performance. Furthermore, the proposed method significantly improves PSNR and SSIM values on datasets with three different degradation types, demonstrating an improvement in the subjective quality of the restored images. The source code is publicly available.