Пример #1
0
        private SubsciptionsStore GetSubsciptionsStore(int tenant, string sourceId, string actionId)
        {
            var key   = string.Format("sub/{0}/{1}/{2}", tenant, sourceId, actionId);
            var store = cache.Get(key) as SubsciptionsStore;

            if (store == null)
            {
                if (Interlocked.CompareExchange(ref getsub, 1, 0) == 0)
                {
                    try
                    {
                        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));
                    }
                    finally
                    {
                        getsub = 0;
                    }
                }
                else
                {
                    store = new SubsciptionsStore(Enumerable.Empty <SubscriptionRecord>(), Enumerable.Empty <SubscriptionMethod>());
                }
            }
            return(store);
        }
Пример #2
0
        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);
        }