Beispiel #1
0
        public static void SubscribeWith <TResponse>(this ISubscriptionManager manager, R.Responses_Paged <TResponse> dto, Q.Queries_Paged <TResponse> query, String Session)
        {
            var key = query.GetCacheKey();

            query.SubscriptionType = query.SubscriptionType ?? ChangeType.ALL;
            foreach (var record in dto.Records)
            {
                manager.Manage(record, key, query.SubscriptionId, query.SubscriptionType ?? ChangeType.ALL, TimeSpan.FromSeconds(query.SubscriptionTime ?? 3600), Session);
            }
        }
Beispiel #2
0
        public static R.Responses_Paged <TResponse> ToOptimizedCachedResult <TResponse>(this IRequest request, Q.Queries_Paged <TResponse> query, ICacheClient cache, Func <R.Responses_Paged <TResponse> > factory)
        {
            var key    = query.GetCacheKey();
            var cached = cache.GetOrCreate(key, () =>
            {
                var result = factory();
                return(result);
            });

            return(cached);
        }
Beispiel #3
0
        public static async Task <R.Responses_Paged <TResponse> > ToOptimizedCachedResult <TResponse>(this IRequest request, Q.Queries_Paged <TResponse> query, ICacheClient cache, Func <Task <R.Responses_Paged <TResponse> > > factory)
        {
            var key    = query.GetCacheKey();
            var cached = cache.Get <R.Responses_Paged <TResponse> >(key);

            if (cached == null)
            {
                cached = await factory();

                cache.Add(key, cached);
            }

            return(cached);
        }
Beispiel #4
0
        public static async Task <R.Responses_Paged <TResponse> > ToOptimizedCachedAndSubscribedPagedResult <TResponse>(this IRequest request, Q.Queries_Paged <TResponse> query, ICacheClient cache, ISubscriptionManager manager, Func <Task <R.Responses_Paged <TResponse> > > factory)
        {
            var key    = query.GetCacheKey();
            var cached = cache.Get <R.Responses_Paged <TResponse> >(key);

            if (cached == null)
            {
                cached = await factory();

                cache.Add(key, cached);
            }
            manager.SubscribeWith(cached, query, request.GetSessionId());

            return(cached);
        }