public virtual async Task <PaymentPlan[]> GetByIdsAsync(string[] planIds, string responseGroup = null) { var cacheKey = CacheKey.With(GetType(), nameof(GetByIdsAsync), string.Join("-", planIds), responseGroup); return(await _platformMemoryCache.GetOrCreateExclusiveAsync(cacheKey, async cacheEntry => { cacheEntry.AddExpirationToken(PaymentPlanCacheRegion.CreateChangeToken()); var retVal = new List <PaymentPlan>(); using (var repository = _subscriptionRepositoryFactory()) { repository.DisableChangesTracking(); var paymentPlanEntities = await repository.GetPaymentPlansByIdsAsync(planIds); foreach (var paymentPlanEntity in paymentPlanEntities) { var paymentPlan = AbstractTypeFactory <PaymentPlan> .TryCreateInstance(); if (paymentPlan != null) { paymentPlan = paymentPlanEntity.ToModel(paymentPlan); retVal.Add(paymentPlan); cacheEntry.AddExpirationToken(PaymentPlanCacheRegion.CreateChangeToken(paymentPlan)); } } } return retVal.ToArray(); })); }