protected void EnsureGroupMailboxData(StoreSession session)
        {
            this.ClearExpiredCacheData();
            if (this.groupsCache.ContainsKey(session.MailboxGuid))
            {
                return;
            }
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, session.GetADSessionSettings(), 466, "EnsureGroupMailboxData", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\WorkingSet\\Publisher\\WorkingSetPublisher.cs");
            ADUser            adUser;

            if (session.MailboxOwner.ObjectId != null)
            {
                adUser = tenantOrRootOrgRecipientSession.FindADUserByObjectId(session.MailboxOwner.ObjectId);
            }
            else
            {
                adUser = (tenantOrRootOrgRecipientSession.FindByLegacyExchangeDN(session.MailboxOwner.LegacyDn) as ADUser);
            }
            WorkingSetPublisher.GroupMailboxData groupMailboxData = new WorkingSetPublisher.GroupMailboxData
            {
                TargetUsers = this.CalculateTargetUsers(adUser, tenantOrRootOrgRecipientSession, session),
                TimeStamp   = DateTime.UtcNow
            };
            if (groupMailboxData.TargetUsers.Count > WorkingSetPublisherConfiguration.MaxTargetUsersToCachePerModernGroup)
            {
                groupMailboxData.TimeStamp -= WorkingSetPublisherConfiguration.ModernGroupsDataExpiryTime;
            }
            this.groupsCache[session.MailboxGuid] = groupMailboxData;
        }
        private void ClearExpiredCacheData()
        {
            DateTime    utcNow = DateTime.UtcNow;
            List <Guid> list   = new List <Guid>();

            foreach (KeyValuePair <Guid, WorkingSetPublisher.GroupMailboxData> keyValuePair in this.groupsCache)
            {
                if (utcNow - keyValuePair.Value.TimeStamp > WorkingSetPublisherConfiguration.ModernGroupsDataExpiryTime)
                {
                    list.Add(keyValuePair.Key);
                }
            }
            foreach (Guid key in list)
            {
                WorkingSetPublisher.GroupMailboxData groupMailboxData = this.groupsCache[key];
                this.groupsCache.Remove(key);
            }
        }