Skip to content

Instantly share code, notes, and snippets.

@shamp00
Created November 1, 2013 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shamp00/7272527 to your computer and use it in GitHub Desktop.
Save shamp00/7272527 to your computer and use it in GitHub Desktop.
StackOverflow caching routine from Marco Cecconi's presentation (https://www.youtube.com/watch?v=t6kM2EM6so4)
private static List<HelpPost> All()
{
return Current
.GlobalCache
.GetSet<List<HelpPost>>(
CacheKey,
(old, ctx) =>
{
using (SiteDBContext siteDb = SiteDBContext.NewContext())
{
return siteDb.Query<HelpPost>("SELECT p.Id, p.Title, etc...");
}
}, 24 * 60 * 60, 24 * 60 * 60)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment