public QueryPlanCache(ISessionFactoryImplementor factory)
        {
            this.factory = factory;

            sqlParamMetadataCache = new SimpleMRUCache(factory.Settings.QueryPlanCacheParameterMetadataMaxSize);
            planCache             = new SoftLimitMRUCache(factory.Settings.QueryPlanCacheMaxSize);
        }
Exemple #2
0
        public ProjectCacheService(Workspace workspace, int implicitCacheTimeout)
        {
            _workspace = workspace;

            _implicitCache        = new SimpleMRUCache();
            _implicitCacheMonitor = new ImplicitCacheMonitor(this, implicitCacheTimeout);
        }
Exemple #3
0
        public static T Cache <T, TKey>(this SimpleMRUCache cache, TKey key, Func <TKey, T> @select)
        {
            var cached = (T)cache[key];

            if (!Equals(cached, default(T)))
            {
                return(cached);
            }
            cached = @select(key);
            cache.Put(key, cached);
            return(cached);
        }
Exemple #4
0
        public ProjectCacheService(Workspace workspace, int implicitCacheTimeout)
        {
            _workspace = workspace;

            // Only create implicit cache for Visual Studio Workspace (the cost of the
            // cache likely outweighs the benefit for the other types of Workspaces).
            if (workspace?.Kind == WorkspaceKind.Host)
            {
                _implicitCache        = new SimpleMRUCache();
                _implicitCacheMonitor = new ImplicitCacheMonitor(this, implicitCacheTimeout);
            }
        }
        public static List <StockAction> LoadStockActions(IStatelessSession session, SimpleMRUCache cache,
                                                          Settings settings, Stock Stock)
        {
            if (Stock == null)
            {
                return(new List <StockAction>());
            }
            var query = session.Query <StockAction>()
                        .Where(x => x.ClientStockId == Stock.Id);

            return(query
                   .ToList());
        }
        public static List <Stock> LoadStoks(IStatelessSession session, SimpleMRUCache cache,
                                             Settings settings, AddressStock AddressStock, Catalog Catalog)
        {
            if (AddressStock == null)
            {
                return(new List <Stock>());
            }
            var query = session.Query <Stock>()
                        .Fetch(x => x.Address)
                        .Where(x => x.Status == StockStatus.Available)
                        .Where(x => x.ProductId == Catalog.Id);

            return(query
                   .ToList());
        }
        public static List <AddressStock> LoadAddressStock(IStatelessSession session, SimpleMRUCache cache,
                                                           Settings settings, Catalog Catalog)
        {
            if (Catalog == null)
            {
                return(new List <AddressStock>());
            }
            var query = session.Query <Stock>()
                        .Where(p => p.Status == StockStatus.Available)
                        .Where(p => p.ProductId == Catalog.Id);

            return(query.Fetch(y => y.Address).OrderBy(y => y.Product)
                   .GroupBy(l => l.Address)
                   .Select(cl => new AddressStock
            {
                Address = cl.First().Address,
                Quantity = cl.Sum(c => c.Quantity),
                ReservedQuantity = cl.Sum(c => c.ReservedQuantity)
            }).ToList());
        }
Exemple #8
0
 public static List <SentOrderLine> LoadOrderHistory(IStatelessSession session, SimpleMRUCache cache,
                                                     Settings settings, BaseOffer offer, Address address)
 {
     if (offer == null || address == null)
     {
         return(new List <SentOrderLine>());
     }
     return(cache.Cache(HistoryOrdersCacheKey(settings, offer), k => {
         IQueryable <SentOrderLine> query = session.Query <SentOrderLine>()
                                            .OrderByDescending(o => o.Order.SentOn);
         //ошибка в nhibernate, если .Where(o => o.Order.Address == Address)
         //переместить в общий блок то первый
         //where применяться не будет
         var addressId = address.Id;
         if (settings.GroupByProduct)
         {
             var productId = offer.ProductId;
             query = query.Where(o => o.ProductId == productId)
                     .Where(o => o.Order.Address.Id == addressId);
         }
         else
         {
             var catalogId = offer.CatalogId;
             query = query.Where(o => o.CatalogId == catalogId)
                     .Where(o => o.Order.Address.Id == addressId);
         }
         return query
         .Fetch(l => l.Order)
         .ThenFetch(o => o.Price)
         .Take(20)
         .ToList();
     }));
 }