wrote functionality for caching documents in memory