First commit: added basic caching.

This first commit is a proof of concept for the caching mechanism. It provides
simple memoization.