예제 #1
0
        public void AddCartToCache(CommerceCart cart)
        {
            var cacheProvider = GetCacheProvider();
            var id            = GetCustomerId(cart.CustomerId);

            if (cacheProvider.Contains(CommerceConstants.KnownCachePrefixes.Sitecore, CommerceConstants.KnownCacheNames.CommerceCartCache, id))
            {
                CommerceTrace.Current.Write($"CartCacheHelper::AddCartToCache - Cart for customer id {id} is already in the cache!");
            }

            cacheProvider.AddData(CommerceConstants.KnownCachePrefixes.Sitecore, CommerceConstants.KnownCacheNames.CommerceCartCache, id, cart);
            CartCookieHelper.CreateCartCookieForCustomer(id);
        }
예제 #2
0
        public void InvalidateCartCache(string customerId)
        {
            var cacheProvider = GetCacheProvider();
            var id            = GetCustomerId(customerId);

            if (!cacheProvider.Contains(CommerceConstants.KnownCachePrefixes.Sitecore, CommerceConstants.KnownCacheNames.CommerceCartCache, id))
            {
                CommerceTrace.Current.Write($"CartCacheHelper::InvalidateCartCache - Cart for customer id {id} is not in the cache!");
            }

            cacheProvider.RemoveData(CommerceConstants.KnownCachePrefixes.Sitecore, CommerceConstants.KnownCacheNames.CommerceCartCache, id);

            CartCookieHelper.DeleteCartCookieForCustomer(id);
        }