index: write out the tree cache extension

Keeping the cache around after read-tree is only one part of the
optimisation opportunities. In order to share the cache between program
instances, we need to write the TREE extension to the index.

Do so. The included test is rather trivial, but works as a sanity check.