code_junkie

Locking HttpRuntime.Cache for lazy loading

Nov 13th, 2011
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. lock (locker)
  2. {
  3. if (HttpRuntime.Cache[cacheKey] == null)
  4. {
  5. HttpRuntime.Cache.Insert(cacheKey, GetSomeDataToCache(), null, DateTime.Today.AddDays(1), Cache.NoSlidingExpiration);
  6. }
  7. return ((SomeData)HttpRuntime.Cache[cacheKey]).Copy();
  8. }
Add Comment
Please, Sign In to add comment