Add a LRU cache and use it for CachedFunction.

This is an early implementation that can still be greatly optimized
(performance, thread safety, etc.). Close #72.
[cmake] Synchronize.