public async Task <JsonResult> GetAll() { if (!_cache.TryGetValue("AutocompleteValues", out IEnumerable <string> cacheEntry)) { cacheEntry = await _catalogService.AutocompleteGetAll(); var cacheEntryOptions = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(TimeSpan.FromMinutes(10)); _cache.Set("AutocompleteValues", cacheEntry, cacheEntryOptions); } else { cacheEntry = (IEnumerable <string>)_cache.Get("AutocompleteValues"); } return(Json(cacheEntry)); }