Esempio n. 1
0
        /// <summary>
        /// Refreshes the runtime cache
        /// </summary>
        /// <param name="merchelloContext">The merchello context</param>
        /// <param name="backoffice">The <see cref="IBackoffice"/></param>
        public static void Refresh(IMerchelloContext merchelloContext, IBackoffice backoffice)
        {
            var cacheKey = MakeCacheKey(backoffice.Customer);

            merchelloContext.Cache.RuntimeCache.ClearCacheItem(cacheKey);

            var customerItemCache = merchelloContext.Services.ItemCacheService.GetItemCacheWithKey(backoffice.Customer, ItemCacheType.Backoffice);

            backoffice = new Backoffice(customerItemCache, backoffice.Customer);
            merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey, () => backoffice);
        }
Esempio n. 2
0
        /// <summary>
        /// Instantiates a backoffice
        /// </summary>
        /// <param name="merchelloContext">The merchello context</param>
        /// <param name="customer">The customer associated with the backoffice</param>
        /// <returns>The <see cref="IBackoffice"/></returns>
        internal static IBackoffice GetBackoffice(IMerchelloContext merchelloContext, ICustomerBase customer)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
            Mandate.ParameterNotNull(customer, "customer");

            var cacheKey = MakeCacheKey(customer);

            var backoffice = (IBackoffice)merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey);

            if (backoffice != null)
            {
                return(backoffice);
            }

            var customerItemCache = merchelloContext.Services.ItemCacheService.GetItemCacheWithKey(customer, ItemCacheType.Backoffice);

            backoffice = new Backoffice(customerItemCache, customer);

            merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey, () => backoffice);

            return(backoffice);
        }
Esempio n. 3
0
        /// <summary>
        /// Instantiates a backoffice
        /// </summary>
        /// <param name="merchelloContext">The merchello context</param>
        /// <param name="customer">The customer associated with the backoffice</param>
        /// <returns>The <see cref="IBackoffice"/></returns>
        internal static IBackoffice GetBackoffice(IMerchelloContext merchelloContext, ICustomerBase customer)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
            Mandate.ParameterNotNull(customer, "customer");

            var cacheKey = MakeCacheKey(customer);

            var backoffice = (IBackoffice)merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey);

            if (backoffice != null) return backoffice;

            var customerItemCache = merchelloContext.Services.ItemCacheService.GetItemCacheWithKey(customer, ItemCacheType.Backoffice);

            backoffice = new Backoffice(customerItemCache, customer);

            merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey, () => backoffice);

            return backoffice;
        }
Esempio n. 4
0
        /// <summary>
        /// Refreshes the runtime cache
        /// </summary>
        /// <param name="merchelloContext">The merchello context</param>
        /// <param name="backoffice">The <see cref="IBackoffice"/></param>
        public static void Refresh(IMerchelloContext merchelloContext, IBackoffice backoffice)
        {
            var cacheKey = MakeCacheKey(backoffice.Customer);
            merchelloContext.Cache.RuntimeCache.ClearCacheItem(cacheKey);

            var customerItemCache = merchelloContext.Services.ItemCacheService.GetItemCacheWithKey(backoffice.Customer, ItemCacheType.Backoffice);
            backoffice = new Backoffice(customerItemCache, backoffice.Customer);
            merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey, () => backoffice);
        }