/// <summary> /// Gets the account. Results are cached. /// </summary> /// <param name="providerKey">The provider key.</param> /// <returns></returns> public Account GetAccount(string providerKey) { string cacheKey = ProfileCache.CreateCacheKey("account", providerKey); Account account = null; object cachedObject = ProfileCache.Get(cacheKey); if (cachedObject != null) { account = (Account)cachedObject; } // Load the object if (account == null) { lock (ProfileCache.GetLock(cacheKey)) { cachedObject = ProfileCache.Get(cacheKey); if (cachedObject != null) { account = (Account)cachedObject; } else { account = Account.LoadByProviderKey(providerKey); // Insert to the cache collection ProfileCache.Insert(cacheKey, account, ProfileConfiguration.Instance.Cache.UserTimeout); } } } return(account); }
/// <summary> /// Gets the organization. Results are cached. /// </summary> /// <param name="principalId">The principal id.</param> /// <returns></returns> public Organization GetOrganization(Guid principalId) { string cacheKey = ProfileCache.CreateCacheKey("org", principalId.ToString()); Organization organization = null; object cachedObject = ProfileCache.Get(cacheKey); if (cachedObject != null) { organization = (Organization)cachedObject; } // Load the object if (organization == null) { lock (ProfileCache.GetLock(cacheKey)) { cachedObject = ProfileCache.Get(cacheKey); if (cachedObject != null) { organization = (Organization)cachedObject; } else { organization = Organization.LoadByPrincipalId(principalId); // Insert to the cache collection ProfileCache.Insert(cacheKey, organization, ProfileConfiguration.Instance.Cache.UserTimeout); } } } return(organization); }