title: Does spark automatically cache some results?
body: <p>I run an action two times, and the second time takes very little time to run, so I suspect that spark automatically cache some results. But I did find any source.</p>
  
  <p>Im using Spark1.4.</p>
  
  <pre><code>doc = sc.textFile('...')
  doc_wc = doc.flatMap(lambda x: re.split('\W', x))\
              .filter(lambda x: x != '') \
              .map(lambda word: (word, 1)) \
              .reduceByKey(lambda x,y: x+y) 
  %%time
  doc_wc.take(5) # first time
  # CPU times: user 10.7 ms, sys: 425 µs, total: 11.1 ms
  # Wall time: 4.39 s
  
  %%time
  doc_wc.take(5) # second time
  # CPU times: user 6.13 ms, sys: 276 µs, total: 6.41 ms
  # Wall time: 151 ms
  </code></pre>