Contact me!
Eric Håård
+46 (0) 73 375 86 06

Cache

The following describes how to set up caching when using the Storm API.

To configure caching add the following to the unity section of your configuration file:

<assembly name="Enferno.Public" />
<namespace name="Enferno.Public.Caching" />

 <container>
      <register type="ICacheManager" mapTo="CacheManager">
        <lifetime type="singleton" />
        <method name="AddCache">
          <param name="cache" dependencyName="AccessClient" />
        </method>
      </register>
      <register name="AccessClient" type="ICache" mapTo="InMemoryCache">
        <lifetime type="singleton" />
        <constructor>
          <param name="name" value="AccessClient" />
        </constructor>
      </register>
    </container>

The CacheManager can handle multiple caches. Above configuration just adds support for caching to the AccessClient. If one more cache is wanted just add another method section with name=”AddCache” under the ICacheManager registration. And then add a new registration for the new cache, equal to the one named “AccessClient” above.

When using a cache for the AccessClient a cache definition file must be used to define which calls to cache and how. The file must be placed in the App_Data folder of your website and named AccessClient.Cache.xml.

Here’s a sample of that file:

<?xml version="1.0" encoding="utf-8"?>
<CacheConfiguration name="AccessClient" duration="300">
  <Item name="ClearBasket" duration="0" redirectformat="Basket{0};Checkout{0}" propertypath="Id"/>
  <Item name="CreateCustomer" duration="0" redirectformat="Customer{0}" propertypath="Id"/>
  <Item name="DeleteBasketItem" duration="0" redirectformat="Basket{0};Checkout{0}" propertypath="Id"/>
  <Item name="GetAgreementAccount"/>
  <Item name="GetApplication"/>
  <Item name="GetBasket" redirectformat="Basket{0}" propertypath="Id"/>
  <Item name="GetCheckout" redirectformat="Checkout{0}" propertypath="Basket.Id"/>
  <Item name="GetCustomer" redirectformat="Customer{0}" propertypath="Id"/>
  <Item name="GetCustomerByEmail" redirectformat="Customer{0}" propertypath="Id"/>
  <Item name="GetManufacturer"/>
  <Item name="GetManufacturerByUniqueName"/>
  <Item name="GetNavigationStructure"/>
  <Item name="GetProduct"/>
  <Item name="GetProductByUniqueName"/>
  <Item name="InsertBasketItem" duration="0" redirectformat="Basket{0};Checkout{0}" propertypath="Id"/>
  <Item name="ListApplicationFlags"/>
  <Item name="ListCategories"/>
  <Item name="ListCategoryItems"/>
  <Item name="ListFlags"/>
  <Item name="ListManufacturersEx"/>
  <Item name="ListNavigationNodesEx"/>
  <Item name="ListParametricInfo" />
  <Item name="ListParametricValues2" />
  <Item name="ListPopularProducts2"/>
  <Item name="ListProductAccessories3"/>
  <Item name="ListProductCrossSell2"/>
  <Item name="ListProductFiltersByNode"/>
  <Item name="ListProductFlags"/>
  <Item name="ListProductItemFilterValuesByNode"/>
  <Item name="ListProductParametrics"/>
  <Item name="ListProducts2"/>
  <Item name="ListProductsByIds2"/>
  <Item name="ListProductsByNode2"/>
  <Item name="ListProductsInFamilies2"/>
  <Item name="ListStores"/>
  <Item name="Login" redirectformat="Customer{0}" propertypath="Id"/>
  <Item name="LoginAgreementAccount"/>
  <Item name="PaymentCancel" duration="0" redirectformat="Basket{0};Checkout{0}" propertypath="Id"/>
  <Item name="UpdateBasket" duration="0" redirectformat="Basket{0};Checkout{0}" propertypath="Id"/>
  <Item name="UpdateBasketItem" duration="0" redirectformat="Basket{0};Checkout{0}" propertypath="Id"/>
  <Item name="UpdateBuyer" duration="0" redirectformat="Basket{0};Checkout{0}" propertypath="Basket.Id"/>
  <Item name="UpdateCustomer" duration="0" redirectformat="Customer{0}" propertypath="Id"/>
  <Item name="UpdateCustomerDeliveryAddress" duration="0" redirectformat="Customer{0}" propertypath="Id"/>
  <Item name="UpdateDeliveryMethod" duration="0" redirectformat="Basket{0};Checkout{0}" propertypath="Basket.Id"/>
  <Item name="UpdatePaymentMethod" duration="0" redirectformat="Basket{0};Checkout{0}" propertypath="Basket.Id"/>
</CacheConfiguration>