public ActionResult <IEnumerable <MountDTO> > Get() { string cacheKey = "mounts"; // Look for cache key. if (!_cache.TryGetValue(cacheKey, out List <MountDTO> cacheEntry)) { // Key not in cache, so get data. cacheEntry = (List <MountDTO>)_request.AllMountsAndURLs(); // Set cache options. var cacheEntryOptions = // Keep in cache for this time, reset time if accessed. new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromDays(1)); // Save data in cache. _cache.Set(cacheKey, cacheEntry, cacheEntryOptions); } return(Ok(cacheEntry)); }