工作框架各种使用整理---使用Cache

<service verb="get" noun="Products">
        <implements service="sang.product.ProductServices.get#ProductsWithPagination"/>
        <in-parameters>
            <parameter name="productCategoryId" required="true"/>
            <parameter name="geoId" required="true"/>
            <parameter name="level" type="Integer" default-value="1"/>
        </in-parameters>
        <actions>
            <set field="cacheKeyName" from="productCategoryId + '_' + level + '_' + geoId + '_' + pageIndex + '_' + pageSize + '_' + pageNoLimit + '_' + orderByField"/>
            <script>
                def categoryGeoProductCache = ec.cache.getCache('Product_List_By_Category_Geo')
                productList = (List) categoryGeoProductCache.get(cacheKeyName)
            </script>
            <if condition="productList != null"><return/></if>
            <service-call name="sang.moqui.extend.BasicServices.get#ChildGeoIds" in-map="[ geoId: geoId, level: 20 ]" out-map="context"/>
            <set field="geoIds" from="geoIds + [geoId]"/>
            <service-call name="sang.product.CategoryServices.get#ChildProductCategoryIds" out-map="context"
                in-map="[ productCategoryId: productCategoryId, level: level ]"/>

            <set field="paginateMap" from="[pageIndex: pageIndex, pageSize: pageSize, pageNoLimit: pageNoLimit, orderByField: orderByField]"/>
            <entity-find entity-name="sang.product.ProductAndCategoryAndGeo" list="pList" distinct="true" cache="true">
                <search-form-inputs input-fields-map="paginateMap"/>
                <date-filter/>
                <econdition field-name="statusId" value="ProductOnShelf"/>
                <econdition field-name="geoId" operator="in" from="geoIds"/>
                <econdition field-name="productCategoryId" operator="in" from="productCategoryIds"/>
                <select-field field-name="productId"/>
            </entity-find>

            <service-call name="sang.product.ProductServices.get#ProductsByIds" in-map="[productIds: pList.productId]" out-map="context"/>
            <service-call name="sang.common.CommonServices.add#PaginateResponseHeaders"
                in-map="[ pageIndex: pageIndex, pageSize: pageSize, totalCount: pListCount, pageMaxIndex: pListPageMaxIndex,
                          pageRangeLow: pListPageRangeLow, pageRangeHigh: pListPageRangeHigh ]"/>
            <script>
                categoryGeoProductCache.put(cacheKeyName, productList)
            </script>
        </actions>
    </service>
 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <moqui-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/moqui-conf-2.0.xsd">
 3 
 4     <cache-list warm-on-start="false">
 5         <cache name="Product_List_By_Category_Geo"  expire-time-live="60"  value-type="List"/>
 6     </cache-list>
 7     <webapp-list>
 8         <webapp name="webroot" https-enabled="false" require-session-token="false">
 9             <after-login><actions>
10             </actions></after-login>
11         </webapp>
12     </webapp-list>
13 </moqui-conf>
原文地址:https://www.cnblogs.com/dream-to-pku/p/5798551.html