Created
November 1, 2013 21:51
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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