public ActionResult Post(WordCountParams param) { // A very naive caching solution if (!_cache.TryGetValue(param.Text, out IEnumerable <WordCountItem> cacheEntry)) { cacheEntry = _wordCountService.GetWordCounts(param.Text); var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromHours(12)); _cache.Set(param.Text, cacheEntry, cacheEntryOptions); } return(Ok(cacheEntry)); }
public void GetWordCounts_EmptyInput() { var results = service.GetWordCounts(string.Empty); Assert.NotNull(results); }