© 2026 Hedgehog Software, LLC
var entity = ...; _cache.CreateEntry(entity.id).SetValue(entity).SetSlidingExpiration(TimeSpan.FromMinutes(ExpirationInMinutes));
public IActionResult CacheTryGetValueSet() { DateTime cacheEntry; if (!_cache.TryGetValue(CacheKeys.Entry, out cacheEntry)) { cacheEntry = DateTime.Now; var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromSeconds(3)); _cache.Set(CacheKeys.Entry, cacheEntry, cacheEntryOptions); } return View("Cache", cacheEntry); }