Next: sep, Previous: noweb-sep, Up: Specific header arguments [Contents][Index]
:cache
The :cache
header argument controls the use of in-buffer caching of
the results of evaluating code blocks. It can be used to avoid re-evaluating
unchanged code blocks. Note that the :cache
header argument will not
attempt to cache results when the :session
header argument is used,
because the results of the code block execution may be stored in the session
outside of the Org mode buffer. The :cache
header argument can have
one of two values: yes
or no
.
no
The default. No caching takes place, and the code block will be evaluated
every time it is called.
yes
Every time the code block is run a SHA1 hash of the code and arguments
passed to the block will be generated. This hash is packed into the
#+RESULTS:
line and will be checked on subsequent
executions of the code block. If the code block has not
changed since the last time it was evaluated, it will not be re-evaluated.
Code block caches notice if the value of a variable argument
to the code block has changed. If this is the case, the cache is
invalidated and the code block is re-run. In the following example,
caller
will not be re-run unless the results of random
have
changed since it was last run.
#+NAME: random #+BEGIN_SRC R :cache yes runif(1) #+END_SRC #+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random 0.4659510825295 #+NAME: caller #+BEGIN_SRC emacs-lisp :var x=random :cache yes x #+END_SRC #+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller 0.254227238707244