Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal static User GetUserByID(int userID)
- {
- string Key = "User-" + userID;
- if (HttpContext.Current.Cache[Key] == null)
- {
- // cache is empty - populate from DB
- var user = new User(UserManager.GetUserInfoByID(userID));
- // store in cache
- HttpContext.Current.Cache.Insert(Key, user, null, DateTime.Now.AddMinutes(5), Cache.NoSlidingExpiration);
- }
- // return data from cache
- return HttpContext.Current.Cache[Key] as User;
- }
Add Comment
Please, Sign In to add comment