public CachedSubscriptionService(DbSubscriptionService service, SubscriptionServiceCache subscriptionServiceCache)
 {
     this.service    = service ?? throw new ArgumentNullException("service");
     cache           = subscriptionServiceCache.Cache;
     notifyRecord    = subscriptionServiceCache.NotifyRecord;
     notifyMethod    = subscriptionServiceCache.NotifyMethod;
     CacheExpiration = TimeSpan.FromMinutes(5);
 }
        private SubsciptionsStore GetSubsciptionsStore(int tenant, string sourceId, string actionId)
        {
            var key   = SubscriptionServiceCache.GetKey(tenant, sourceId, actionId);
            var store = cache.Get <SubsciptionsStore>(key);

            if (store == null)
            {
                var records = service.GetSubscriptions(tenant, sourceId, actionId);
                var methods = service.GetSubscriptionMethods(tenant, sourceId, actionId, null);
                cache.Insert(key, store = new SubsciptionsStore(records, methods), DateTime.UtcNow.Add(CacheExpiration));
            }
            return(store);
        }