public static UserInfo GetUser(string upn, bool clearCache = false) { if (clearCache) { MemCache.Clear(upn); } var result = (UserInfo)MemCache.Get(upn); if (result == null) { using (var ctx = new ClientContext(SharePointHelper.Url)) { var u = ctx.Web.EnsureUser(upn); ctx.Load(u); ctx.Load(u.Groups); ctx.ExecuteQuery(); result = MapToModel(u); MemCache.Add(upn, result); } } return(result); }
public void Clear() { _cache.Store("key", 123, Encoding.ASCII.GetBytes("12345"), new DateTime(1999, 1, 1)); _cache.Clear(); Assert.AreEqual(2, _testObserver.Messages.Count); var storeNotification = GetNotification(); Assert.IsInstanceOfType(storeNotification, typeof(StoreNotification)); var clearNotification = GetNotification(1); Assert.IsInstanceOfType(clearNotification, typeof(ClearNotification)); }