예제 #1
0
        private static void InsertIntoCache(HttpContext httpContext, IMailboxContext userContext)
        {
            UserContextManager.UserContextCacheWrapper userContextCacheWrapper = (UserContextManager.UserContextCacheWrapper)HttpRuntime.Cache.Get(userContext.Key.ToString());
            if (userContextCacheWrapper == null)
            {
                userContextCacheWrapper = new UserContextManager.UserContextCacheWrapper
                {
                    Lock = new OwaRWLockWrapper()
                };
            }
            UserContextManager.TombstoneExistingUserContext(userContextCacheWrapper);
            userContextCacheWrapper.UserContext = userContext;
            int num = UserContextManager.UserContextTimeout;

            if (UserAgentUtilities.IsMonitoringRequest(httpContext.Request.UserAgent))
            {
                num = 1;
                if (userContext.UserPrincipalName.EndsWith(".exchangemon.net", StringComparison.InvariantCultureIgnoreCase))
                {
                    ExMonitoringRequestTracker.Instance.ReportMonitoringRequest(httpContext.Request);
                }
            }
            HttpRuntime.Cache.Insert(userContext.Key.ToString(), userContextCacheWrapper, null, DateTime.MaxValue, new TimeSpan((long)num * 600000000L), CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(UserContextManager.UserContextRemovedCallback));
            userContext.LogBreadcrumb("Cached:Key=" + userContext.Key.ToString());
        }