Made persistent caching into a contextmanager.