예제 #1
0
        internal static DelegatedPrincipalCacheData GetEntry(string targetOrgId, string userId, string securityToken)
        {
            DelegatedPrincipalCache.CacheKey key = new DelegatedPrincipalCache.CacheKey(targetOrgId, userId, securityToken);
            DelegatedPrincipalCacheData      delegatedPrincipalCacheData = null;

            if (DelegatedPrincipalCache.delegatedCache.ContainsKey(key))
            {
                lock (DelegatedPrincipalCache.syncObj)
                {
                    if (DelegatedPrincipalCache.delegatedCache.TryGetValue(key, out delegatedPrincipalCacheData))
                    {
                        if (delegatedPrincipalCacheData != null && DelegatedPrincipalCache.IsCacheBucketExpired(delegatedPrincipalCacheData))
                        {
                            DelegatedPrincipalCache.delegatedCache.Remove(key);
                            delegatedPrincipalCacheData = null;
                        }
                        else
                        {
                            delegatedPrincipalCacheData.LastReadTime = DateTime.UtcNow;
                        }
                    }
                }
            }
            return(delegatedPrincipalCacheData);
        }
예제 #2
0
        internal static bool RemoveEntry(string targetOrgId, string userId, string securityToken)
        {
            DelegatedPrincipalCache.CacheKey key = new DelegatedPrincipalCache.CacheKey(targetOrgId, userId, securityToken);
            bool result;

            lock (DelegatedPrincipalCache.syncObj)
            {
                result = DelegatedPrincipalCache.delegatedCache.Remove(key);
            }
            return(result);
        }
예제 #3
0
        internal static bool TrySetEntry(string targetOrgId, string userId, string securityToken, DelegatedPrincipalCacheData data)
        {
            DelegatedPrincipalCache.CacheKey key = new DelegatedPrincipalCache.CacheKey(targetOrgId, userId, securityToken);
            bool result = false;

            lock (DelegatedPrincipalCache.syncObj)
            {
                if (DelegatedPrincipalCache.delegatedCache.Count < 5000)
                {
                    DelegatedPrincipalCache.delegatedCache[key] = data;
                    result = true;
                }
            }
            return(result);
        }