Wednesday, March 16, 2016

Rest Services Caching in Websphere Commercer

From FEB7 onwards, We are using all the services via rest, So for performance consideration, we can cache the rest service calls also.

Use the following way to cache the rest services.

We have to create a new cachespec.xml and place it in Search-Rest/WebContent/ folder. then after the server restarts,the rest services calls also started caching and monitor from cache monitor tool.

In the XML Contains,

<?xml version="1.0"    ?>
<!DOCTYPE cache    SYSTEM "cachespec.dtd">

<!--
 =================================================================
  Licensed Materials - Property of IBM

  WebSphere Commerce

  (C) Copyright IBM Corp. 2011 All Rights Reserved.

  US Government Users Restricted Rights - Use, duplication or
  disclosure restricted by GSA ADP Schedule Contract with
  IBM Corp.
 =================================================================
-->

<!-- ******************************************************************************************************************** -->
<!-- * RESTful Services cachespec.xml.                                                                                  * -->
<!-- *                                                                                                                  * -->
<!-- * This sample is provided as an example on how to set up caching for the RESTful Services URLs.                    * -->
<!-- *                                                                                                                  * -->
<!-- * The RESTCacheFilter extracts the path parameters and sets it as request attributes.                              * -->
<!-- * The request attributes are then used to build cache-ids.                                                         * -->
<!-- * The cache-id rules are then applied to determine which of the following URLs are cached.                         * -->
<!-- *                                                                                                                  * -->
<!-- * /wcs/resources/store/{storeId}/categoryview/@top                                                                 * -->
<!-- * /wcs/resources/store/{storeid}/categoryview/{categoryIdentifier}                                                 * -->
<!-- * /wcs/resources/store/{storeid}/categoryview/byId/{uniqueID}                                                      * -->
<!-- * /wcs/resources/store/{storeid}/productview/{partnumber}                                                          * -->
<!-- * /wcs/resources/store/{storeid}/productview/byId/{uniqueID}                                                       * -->
<!-- * /wcs/resources/store/{storeId}/productview/byCategory/{category_unique_id}                                       * -->
<!-- * /wcs/resources/store/{storeId}/espot/{espotIdentifier}                                                           * -->
<!-- * /wcs/resources/store/{storeId}/espot/{espotIdentifier}/category/{categoryId}                                     * --> 
<!-- * /wcs/resources/store/{storeId}/espot/{espotIdentifier}/product/{productId}                                       * -->
<!-- * /wcs/resources/store/{storeId}/productview/bySearchTerm/{searchTerm}?pageNumber={pageNumber}&pageSize={pageSize} * -->
<!-- * /wcs/resources/store/{storeId}/productview/bySearchTerm/{searchTerm}?metaData={metaDataValue}                    * -->
<!-- *                                                                                                                  * -->
<!-- * Available request attributes                                                                                     * -->
<!-- * storeId. {storeId}                                                                                               * -->
<!-- * catalogId. {catalogId}                                                                                           * -->
<!-- * productId. product id of the {partnumber}, {productId}, {uniqueId} of product URL                                * -->
<!-- * categoryId. category id of the {groupId}, {categoryId}, {category_unique_id}, {uniqueId} of category URL         * -->
<!-- * espotId. {espotIdentifier}                                                                                       * -->
<!-- * searchTerm. {searchTerm}                                                                                         * -->
<!-- * action. possible values: [productDisplay | categoryDisplay]                                                      * -->
<!-- * urlType. possible values: [topCategories | espot | search]                                                       * -->
<!-- *                                                                                                                  * -->
<!-- * The dependency-ids are generated to match the invalidation scheme defined in other sample cachespec.xmls         * -->
<!-- * This cachespec must be used in conjunction with those cachespecs where the invalidation schemes are defined.     * -->
<!-- * See the cachespec.xml under invalidation/store and invalidation/catalog                                          * -->
<!-- ******************************************************************************************************************** -->

<cache>
 
  <cache-entry>
      <class>servlet</class>
      <name>org.apache.wink.server.internal.servlet.RestServlet.class</name>
     
      <cache-id>
         <property name="ignore-get-post">true</property>
        
         <component id="urlPath" type="pathinfo">
            <required>true</required>
         </component>
         <component id="method" type="requestType">
             <required>true</required>
             <value>GET</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="catalogId" type="attribute">
            <required>true</required>
         </component>
         <component id="projectId" type="attribute">
            <required>true</required>
         </component>
       
      </cache-id>
      <dependency-id>projectId
        <component id="projectId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
      <dependency-id>storeId:projectId
        <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="projectId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
     
     
     
      <!-- /wcs/resources/store/{storeId}/categoryview/@top -->
      <cache-id>
         <property name="ignore-get-post">true</property>
         <component id="urlPath" type="pathinfo">
            <required>true</required>
         </component>
         <component id="method" type="requestType">
             <required>true</required>
             <value>GET</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="catalogId" type="attribute">
            <required>true</required>
         </component>
         <component id="urlType" type="attribute">
            <required>true</required>
            <value>topCategories</value>
         </component>
         <component id="responseFormat" type="parameter">
            <required>false</required>
         </component>
         <component id="langId" type="parameter">
            <required>false</required>
         </component>
         <component id="currency" type="parameter">
            <required>false</required>
         </component>
         <component id="locale" type="parameter">
            <required>false</required>
         </component>     
      </cache-id>
      <dependency-id>TopCategoriesDisplay:storeId:catalogId
      <component id="urlType" type="attribute" ignore-value="true">
            <required>true</required>
            <value>topCategories</value>
         </component>
        <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="catalogId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
      
      <!-- /wcs/resources/store/{storeid}/categoryview/{categoryIdentifier} -->
      <!-- /wcs/resources/store/{storeid}/categoryview/byId/{uniqueID} -->
      <!-- /wcs/resources/store/{storeId}/product/byCategory/{category_unique_id} -->
      <!-- /wcs/resources/store/{storeId}/espot/{espotIdentifier}/category/{categoryId}  -->      
       <cache-id>
         <property name="ignore-get-post">true</property>
         <component id="urlPath" type="pathinfo">
            <required>true</required>
         </component>
         <component id="method" type="requestType">
             <required>true</required>
             <value>GET</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="catalogId" type="attribute">
            <required>true</required>
         </component>
         <component id="espotId" type="attribute">
            <required>false</required>
         </component>
         <component id="categoryId" type="attribute">
            <required>true</required>
         </component>
         <component id="responseFormat" type="parameter">
            <required>false</required>
         </component>
         <component id="langId" type="parameter">
            <required>false</required>
         </component>
         <component id="currency" type="parameter">
            <required>false</required>
         </component>
         <component id="locale" type="parameter">
            <required>false</required>
         </component>
         <component id="pageNumber" type="parameter">
            <required>false</required>
         </component>
         <component id="pageSize" type="parameter">
            <required>false</required>
         </component>
      </cache-id>
      <dependency-id>categoryId
        <component id="categoryId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
      <dependency-id>storeId:categoryId
        <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="categoryId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
       <dependency-id>TopCategoriesDisplay:storeId:categoryId
        <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="categoryId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
       <dependency-id>CategoryDisplay:storeId:categoryId
        <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="categoryId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
      
       <!-- /wcs/resources/store/{storeid}/productview/{partnumber} -->
       <!-- /wcs/resources/store/{storeid}/productview/byId/{uniqueID} -->
       <!-- /wcs/resources/store/{storeId}/espot/{espotIdentifier}/product/{productId} -->
       <cache-id>
         <property name="ignore-get-post">true</property>
         <component id="urlPath" type="pathinfo">
            <required>true</required>
         </component>
         <component id="method" type="requestType">
             <required>true</required>
             <value>GET</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="catalogId" type="attribute">
            <required>true</required>
         </component>
         <component id="espotId" type="attribute">
            <required>false</required>
         </component>
         <component id="productId" type="attribute">
            <required>true</required>
         </component>
         <component id="responseFormat" type="parameter">
            <required>false</required>
         </component>
         <component id="langId" type="parameter">
            <required>false</required>
         </component>
         <component id="currency" type="parameter">
            <required>false</required>
         </component>
         <component id="locale" type="parameter">
            <required>false</required>
         </component>
         <component id="pageNumber" type="parameter">
            <required>false</required>
         </component>
         <component id="pageSize" type="parameter">
            <required>false</required>
         </component>
      </cache-id>
      <dependency-id>productId
        <component id="productId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
      <dependency-id>storeId:productId
        <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="productId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
       <dependency-id>ProductDisplay:storeId:productId
        <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="productId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
      
       <!-- /wcs/resources/store/{storeId}/espot/{espotIdentifier} -->
       <cache-id>
         <property name="ignore-get-post">true</property>
         <component id="urlPath" type="pathinfo">
            <required>true</required>
         </component>
         <component id="method" type="requestType">
             <required>true</required>
             <value>GET</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="catalogId" type="attribute">
            <required>true</required>
         </component>
         <component id="espotId" type="attribute">
            <required>true</required>
         </component>
         <component id="urlType" type="attribute">
            <required>true</required>
            <value>espot</value>
         </component>
         <component id="responseFormat" type="parameter">
            <required>false</required>
         </component>
         <component id="langId" type="parameter">
            <required>false</required>
         </component>
         <component id="currency" type="parameter">
            <required>false</required>
         </component>
         <component id="locale" type="parameter">
            <required>false</required>
         </component>
      </cache-id>
      <dependency-id>storeId:spotName
        <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="espotId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
      
      
      <!-- /wcs/resources/store/{storeId}/productview/bySearchTerm/{searchTerm}?pageNumber={pageNumber}&pageSize={pageSize} -->
      <!-- /wcs/resources/store/{storeId}/productview/bySearchTerm/{searchTerm}?metaData={metaDataValue} -->
      <cache-id>
     <property name="ignore-get-post">true</property>
     <component id="searchPath" type="pathinfo">
            <required>true</required>
         </component>
         <component id="method" type="requestType">
             <required>true</required>
             <value>GET</value>
         </component>
         <component id="storeId" type="attribute">
                <required>true</required>
         </component>
         <component id="catalogId" type="attribute">
                <required>true</required>
         </component>
         <component id="searchTerm" type="attribute">
                <required>true</required>
         </component>
         <component id="pageView" type="parameter">
            <required>false</required>
     </component>
     <component id="beginIndex" type="parameter">
            <required>false</required>
     </component>
     <component id="pageSize" type="parameter">
            <required>false</required>
     </component>
     <component id="searchType" type="parameter">
        <required>false</required>
     </component>
     <component id="showResultsPage" type="parameter">
        <required>false</required>
     </component>
     <component id="sType" type="parameter">
        <required>false</required>
     </component>
     <component id="resultCatEntryType" type="parameter">
         <required>false</required>
     </component>
     <component id="metaData" type="parameter">
        <required>false</required>
     </component>
     <component id="orderBy" type="parameter">
         <required>false</required>
     </component>
     <component id="searchTermScope" type="parameter">
        <required>false</required>
     </component>
     <component id="facet" type="parameter">
         <required>false</required>
     </component>
     <component id="filterFacet" type="parameter">
        <required>false</required>
     </component>
     <component id="filterTerm" type="parameter">
         <required>false</required>
     </component>
     <component id="filterType" type="parameter">
        <required>false</required>
     </component>
     <component id="manufacturer" type="parameter">
        <required>false</required>
     </component>
     <component id="minPrice" type="parameter">
        <required>false</required>
     </component>
     <component id="maxPrice" type="parameter">
        <required>false</required>
     </component>
     <component id="catGroupId" type="parameter">
        <required>false</required>
     </component>
     <component id="responseFormat" type="parameter">
              <required>false</required>
         </component>
         <component id="langId" type="parameter">
            <required>false</required>
         </component>
         <component id="currency" type="parameter">
             <required>false</required>
         </component>
         <component id="locale" type="parameter">
             <required>false</required>
         </component>
     <component id="orderBy" type="parameter">
             <required>false</required>
         </component>
      </cache-id>
      <dependency-id>storeId
         <component id="urlType" type="attribute" ignore-value="true">
            <required>true</required>
            <value>search</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>        
       </dependency-id>
       <dependency-id>catalogId
         <component id="urlType" type="attribute" ignore-value="true">
            <required>true</required>
            <value>search</value>
         </component>
         <component id="catalogId" type="attribute">
            <required>true</required>
         </component>        
       </dependency-id>
       <dependency-id>storeId:catalogId
         <component id="urlType" type="attribute" ignore-value="true">
            <required>true</required>
            <value>search</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="catalogId" type="attribute">
            <required>true</required>
         </component>        
       </dependency-id>
       <dependency-id>storeId:categoryId
         <component id="urlType" type="attribute" ignore-value="true">
            <required>true</required>
            <value>search</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="categoryId" type="attribute">
            <required>true</required>
         </component>        
       </dependency-id>
       <dependency-id>catalogId:categoryId
         <component id="urlType" type="attribute" ignore-value="true">
            <required>true</required>
            <value>search</value>
         </component>
         <component id="catalogId" type="attribute">
            <required>true</required>
         </component>
         <component id="categoryId" type="attribute">
            <required>true</required>
         </component>        
       </dependency-id>
       <dependency-id>storeId:catalogId:categoryId
         <component id="urlType" type="attribute" ignore-value="true">
            <required>true</required>
            <value>search</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>
         <component id="catalogId" type="attribute">
            <required>true</required>
         </component>
         <component id="categoryId" type="attribute">
            <required>true</required>
         </component>        
       </dependency-id>
      
       <dependency-id>priceRule:storeId
         <component id="action" type="attribute" ignore-value="true">
            <required>true</required>
            <value>productDisplay</value>
            <value>categoryDisplay</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
      
       <dependency-id>catalogFilter:storeId
         <component id="action" type="attribute" ignore-value="true">
            <required>true</required>
            <value>productDisplay</value>
            <value>categoryDisplay</value>
         </component>
         <component id="urlType" type="attribute" ignore-value="true">
            <required>true</required>
            <value>search</value>
            <value>topCategories</value>
         </component>
         <component id="storeId" type="attribute">
            <required>true</required>
         </component>
       </dependency-id>
                   
  </cache-entry>
 
  </cache>

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Thanks also for sharing your knowledge by making this blog. It's really a great help for me. I hope you make more blogs like this.
    ADP Commerce | Riphah International College

    ReplyDelete
  3. It's really a great help for me. I hope you make more blogs like this.
    MBA - Masters of business administration in Lahore

    ReplyDelete