Make the global cache optional.

Now if you explicitly pass in a cache, we'll use it. If not, we just go straight to the datastore.