Added some basic query caching.

This should be enhanced by allowing the objects to be pre compiled