[Issue 294] Add pluggable in-memory caching

This pull request is related to the issue #294.
As far as I can see all you did was move these two methods to another part of the file?  Am I missing something?