Generic cache and timer functions which can be used to decorate functions in a functional fashion.