Factor out a method for getting things from the cache.