private async Task <XacmlPolicy> GetPolicyInternalAsync(string policyPath, string version = "") { if (!_memoryCache.TryGetValue(policyPath + version, out XacmlPolicy policy)) { Stream policyBlob = string.IsNullOrEmpty(version) ? await _repository.GetPolicyAsync(policyPath) : await _repository.GetPolicyVersionAsync(policyPath, version); using (policyBlob) { policy = (policyBlob.Length > 0) ? PolicyHelper.ParsePolicy(policyBlob) : null; } PutXacmlPolicyInCache(policyPath, policy); } return(policy); }