redis 緩存類型為map


    // 獲取分類列表,以及同類品牌
    public Map<String, List> getCatalogInfo(Product product) {

        String key = CacheKeyUtils.getCacheKey(NAMESPACE, product);
        Map<String, List> resutMap = (Map<String, List>) cache.get(key);
        if (null == resutMap) {
            resutMap = new HashMap<String, List>();
            List<ProductCatalog> catalogList = Lists.newArrayList();
            List<ProductBrand> similarCatalogBrands = new ArrayList<ProductBrand>();
            if (product.getProCatalogId() != null) {
                ProductCatalog productCatalog = catalogService.getCatalogById(product.getProCatalogId());
                String fullIndex = productCatalog.getFullIndex().replace(".", ",");
                if (null != fullIndex) {
                    String[] indexes = fullIndex.split(",");
                    if (indexes != null && indexes.length > 1) {
                        // 同類品牌
                        similarCatalogBrands = catalogService.getSimilarCatalogBrands(Integer.parseInt(indexes[1]));
                    }
                    // for (String index : indexes) {
                    // ProductCatalog g =
                    // catalogService.getCatalogById(Integer.parseInt(index));
                    // catalogList.add(g);
                    // }
                    List<Integer> catalogIds = new ArrayList<Integer>();
                    for (String index : indexes) {
                        catalogIds.add(Integer.parseInt(index));
                    }
                    // 分類列表
                    catalogList = catalogService.getCatalogByIds(catalogIds);
                }
            }
            resutMap.put("catalogList", catalogList);
            resutMap.put("similarCatalogBrands", similarCatalogBrands);
            cache.put(key, resutMap, 60);
        }
        return resutMap;
    };

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM