Skip to content

Instantly share code, notes, and snippets.

@ChrisMoney
Last active May 2, 2024 21:52
Show Gist options
  • Save ChrisMoney/0562b6627313f623f9e075341dda3896 to your computer and use it in GitHub Desktop.
Save ChrisMoney/0562b6627313f623f9e075341dda3896 to your computer and use it in GitHub Desktop.
Cache DB Call
if (HttpContext.Current.Cache.Get("ef_results") == null)
{
var results = null; // todo: get results from EF
HttpContext.Current.Cache.Add("ef_results", // cache key
results, // cache value
null, // dependencies
System.Web.Caching.Cache.NoAbsoluteExpiration, // absolute expiration
TimeSpan.FromMinutes(30)); // sliding expiration
}
myDropDown.DataSource = HttpContext.Current.Cache.Get("ef_results");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment