title: How far will Spark RDD cache go?
body: <p>Say I have three <em>RDD</em> transformation function called on <em>rdd1</em>:</p>
  
  <pre><code>def rdd2 = rdd1.f1
  def rdd3 = rdd2.f2
  def rdd4 = rdd3.f3
  </code></pre>
  
  <p>Now I want to cache <code>rdd4</code>, so I call <code>rdd4.cache()</code>.</p>
  
  <p><strong>My question:</strong></p>
  
  <p>Will only the result from the action on <code>rdd4</code> be cached or will every <em>RDD</em> above <code>rdd4</code> be cached? Say I want to cache both <code>rdd3</code> and <code>rdd4</code>, do I need to cache them separately?</p>