Cache() is one of the versions of the persist() method. The persist() method can save the RDD in user-defined storage, such as the main memory or HDD. While cache() stores RDD in the main memory by default, cache() internally calls the persist() method for saving the RDD in the main memory.