public async Task <bool> Exists(string id) { if (MemoryCache.Default.Contains(id)) { return(true); } // the cache does not have the id so lets check the repository var exists = await repository.Exists(id); if (exists) { // store id in cache as it currently exists MemoryCache.Default.Add(id, bool.TrueString, null); } return(exists); }