shopizer-developers
Changes
pom.xml 8(+4 -4)
sm-core/pom.xml 52(+0 -52)
sm-core/src/main/java/com/salesmanager/core/business/services/reference/country/CountryServiceImpl.java 50(+28 -22)
sm-core/src/main/java/com/salesmanager/core/business/services/reference/language/LanguageServiceImpl.java 24(+13 -11)
sm-core/src/main/java/com/salesmanager/core/business/services/reference/zone/ZoneServiceImpl.java 97(+54 -43)
sm-core/src/main/java/com/salesmanager/core/business/services/system/ModuleConfigurationServiceImpl.java 141(+74 -67)
sm-shop/pom.xml 52(+0 -52)
sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java 78(+49 -29)
Details
pom.xml 8(+4 -4)
diff --git a/pom.xml b/pom.xml
index 4a997aa..ed7e200 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,8 +44,8 @@
<dependencies>
<dependency>
- <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
- <artifactId>ApplicationTracer</artifactId>
+ <groupId>br.ufrgs.inf.prosoft.cache</groupId>
+ <artifactId>Cache</artifactId>
<version>1.0</version>
</dependency>
@@ -104,10 +104,10 @@
<!-- https://mvnrepository.com/artifact/net.sf.ehcache/ehcache -->
- <dependency>
+ <!-- <dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
- </dependency>
+ </dependency> -->
<!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
<dependency>
sm-core/pom.xml 52(+0 -52)
diff --git a/sm-core/pom.xml b/sm-core/pom.xml
index 4e8c652..282516c 100644
--- a/sm-core/pom.xml
+++ b/sm-core/pom.xml
@@ -204,56 +204,4 @@
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>aspectj-maven-plugin</artifactId>
- <version>1.11</version>
- <configuration>
- <showWeaveInfo>false</showWeaveInfo>
- <complianceLevel>1.8</complianceLevel>
- <source>1.6</source>
- <target>1.6</target>
- <Xlint>ignore</Xlint>
- <encoding>UTF-8</encoding>
- <verbose>false</verbose>
- <forceAjcCompile>true</forceAjcCompile>
- <sources/>
- <weaveDirectories>
- <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
- </weaveDirectories>
- <aspectLibraries>
- <aspectLibrary>
- <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
- <artifactId>ApplicationTracer</artifactId>
- </aspectLibrary>
- </aspectLibraries>
- </configuration>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>1.9.1</version>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjtools</artifactId>
- <version>1.9.1</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-
-
</project>
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/services/reference/country/CountryServiceImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/services/reference/country/CountryServiceImpl.java
index 38727be..0d744f0 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/services/reference/country/CountryServiceImpl.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/services/reference/country/CountryServiceImpl.java
@@ -7,6 +7,8 @@ import java.util.Map;
import javax.inject.Inject;
+import br.ufrgs.inf.prosoft.cache.MultiCache;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -79,43 +81,47 @@ public class CountryServiceImpl extends SalesManagerEntityServiceImpl<Integer, C
return requestedCountryList;
}
+public static MultiCache<String, List<Country>> getCountriesCache = new MultiCache<>("getCountriesCache");
@SuppressWarnings("unchecked")
@Override
public List<Country> getCountries(Language language) throws ServiceException {
- List<Country> countries = null;
- try {
+ return getCountriesCache.computeIfAbsent("COUNTRIES_" + language.getCode(), () -> {
-// countries = (List<Country>) cache.getFromCache("COUNTRIES_" + language.getCode());
+ List<Country> countries = null;
+ try {
+
+ // countries = (List<Country>) cache.getFromCache("COUNTRIES_" + language.getCode());
-
-
- if(countries==null) {
- countries = countryRepository.listByLanguage(language.getId());
- //set names
- for(Country country : countries) {
-
- CountryDescription description = country.getDescriptions().get(0);
- country.setName(description.getName());
+ if(countries==null) {
+
+ countries = countryRepository.listByLanguage(language.getId());
+
+ //set names
+ for(Country country : countries) {
+
+ CountryDescription description = country.getDescriptions().get(0);
+ country.setName(description.getName());
+
+ }
+ // cache.putInCache(countries, "COUNTRIES_" + language.getCode());
}
-// cache.putInCache(countries, "COUNTRIES_" + language.getCode());
- }
+
+
+ } catch (Exception e) {
+ LOGGER.error("getCountries()", e);
+ }
+
+ return countries;
-
-
- } catch (Exception e) {
- LOGGER.error("getCountries()", e);
- }
-
- return countries;
-
+ }, 1200000);
}
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/services/reference/language/LanguageServiceImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/services/reference/language/LanguageServiceImpl.java
index 074b759..c5005fe 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/services/reference/language/LanguageServiceImpl.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/services/reference/language/LanguageServiceImpl.java
@@ -5,6 +5,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
+import br.ufrgs.inf.prosoft.cache.GetterCache;
+
import javax.inject.Inject;
import org.slf4j.Logger;
@@ -79,28 +81,28 @@ public class LanguageServiceImpl extends SalesManagerEntityServiceImpl<Integer,
}
+public static GetterCache<List<Language>> getLanguagesCache = new GetterCache<>("getLanguagesCache");
@Override
@SuppressWarnings("unchecked")
public List<Language> getLanguages() throws ServiceException {
+ // List<Language> langs = null;
+
+ // langs = (List<Language>) cache.getFromCache("LANGUAGES");
+ // if(langs==null) {
+ // langs = this.list();
+ // cache.putInCache(langs, "LANGUAGES");
+ // }
-
- List<Language> langs = null;
try {
-
-// langs = (List<Language>) cache.getFromCache("LANGUAGES");
- if(langs==null) {
- langs = this.list();
-// cache.putInCache(langs, "LANGUAGES");
- }
-
+ return getLanguagesCache.computeIfAbsent(() -> {
+ return this.list();
+ }, 1200000);
} catch (Exception e) {
LOGGER.error("getCountries()", e);
throw new ServiceException(e);
}
- return langs;
-
}
@Override
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/services/reference/zone/ZoneServiceImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/services/reference/zone/ZoneServiceImpl.java
index 9a94591..630ed24 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/services/reference/zone/ZoneServiceImpl.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/services/reference/zone/ZoneServiceImpl.java
@@ -11,6 +11,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
+import br.ufrgs.inf.prosoft.cache.MultiCache;
+
import com.salesmanager.core.business.constants.Constants;
import com.salesmanager.core.business.exception.ServiceException;
import com.salesmanager.core.business.repositories.reference.zone.ZoneRepository;
@@ -25,7 +27,7 @@ import com.salesmanager.core.model.reference.zone.ZoneDescription;
public class ZoneServiceImpl extends SalesManagerEntityServiceImpl<Long, Zone> implements
ZoneService {
-// private final static String ZONE_CACHE_PREFIX = "ZONES_";
+ private final static String ZONE_CACHE_PREFIX = "ZONES_";
private ZoneRepository zoneRepository;
@@ -59,73 +61,82 @@ public class ZoneServiceImpl extends SalesManagerEntityServiceImpl<Long, Zone> i
update(zone);
}
}
+
+public static MultiCache<String, List<Zone>> getZonesByCountryCache = new MultiCache<>("getZonesByCountryCache");
@SuppressWarnings("unchecked")
@Override
public List<Zone> getZones(Country country, Language language) throws ServiceException {
+ String cacheKey = ZONE_CACHE_PREFIX + country.getIsoCode() + Constants.UNDERSCORE + language.getCode();
+ return getZonesByCountryCache.computeIfAbsent(cacheKey, () -> {
- List<Zone> zones = null;
- try {
+ List<Zone> zones = null;
+ try {
-// String cacheKey = ZONE_CACHE_PREFIX + country.getIsoCode() + Constants.UNDERSCORE + language.getCode();
-
-// zones = (List<Zone>) cache.getFromCache(cacheKey);
+
+ // zones = (List<Zone>) cache.getFromCache(cacheKey);
-
-
- if(zones==null) {
- zones = zoneRepository.listByLanguageAndCountry(country.getIsoCode(), language.getId());
- //set names
- for(Zone zone : zones) {
- ZoneDescription description = zone.getDescriptions().get(0);
- zone.setName(description.getName());
-
+ if(zones==null) {
+
+ zones = zoneRepository.listByLanguageAndCountry(country.getIsoCode(), language.getId());
+
+ //set names
+ for(Zone zone : zones) {
+ ZoneDescription description = zone.getDescriptions().get(0);
+ zone.setName(description.getName());
+
+ }
+ // cache.putInCache(zones, cacheKey);
}
-// cache.putInCache(zones, cacheKey);
- }
- } catch (Exception e) {
- LOGGER.error("getZones()", e);
- }
- return zones;
+ } catch (Exception e) {
+ LOGGER.error("getZones()", e);
+ }
+ return zones;
+ }, 1200000);
}
+public static MultiCache<String, Map<String, Zone>> getZonesByLanguageCache = new MultiCache<>("getZonesByLanguageCache");
+
@Override
@SuppressWarnings("unchecked")
public Map<String, Zone> getZones(Language language) throws ServiceException {
- Map<String, Zone> zones = null;
- try {
+ String cacheKey = ZONE_CACHE_PREFIX + language.getCode();
+ return getZonesByLanguageCache.computeIfAbsent(cacheKey, () -> {
-// String cacheKey = ZONE_CACHE_PREFIX + language.getCode();
-
-// zones = (Map<String, Zone>) cache.getFromCache(cacheKey);
+ Map<String, Zone> zones = null;
+ try {
+
+
+ // zones = (Map<String, Zone>) cache.getFromCache(cacheKey);
-
-
- if(zones==null) {
- zones = new HashMap<String, Zone>();
- List<Zone> zns = zoneRepository.listByLanguage(language.getId());
- //set names
- for(Zone zone : zns) {
- ZoneDescription description = zone.getDescriptions().get(0);
- zone.setName(description.getName());
- zones.put(zone.getCode(), zone);
-
+
+ if(zones==null) {
+ zones = new HashMap<String, Zone>();
+ List<Zone> zns = zoneRepository.listByLanguage(language.getId());
+
+ //set names
+ for(Zone zone : zns) {
+ ZoneDescription description = zone.getDescriptions().get(0);
+ zone.setName(description.getName());
+ zones.put(zone.getCode(), zone);
+
+ }
+ // cache.putInCache(zones, cacheKey);
}
-// cache.putInCache(zones, cacheKey);
- }
- } catch (Exception e) {
- LOGGER.error("getZones()", e);
- }
- return zones;
+ } catch (Exception e) {
+ LOGGER.error("getZones()", e);
+ }
+ return zones;
+ }, 1200000);
}
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/services/system/ModuleConfigurationServiceImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/services/system/ModuleConfigurationServiceImpl.java
index 7e3f0a2..4166632 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/services/system/ModuleConfigurationServiceImpl.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/services/system/ModuleConfigurationServiceImpl.java
@@ -7,6 +7,8 @@ import java.util.Map;
import javax.inject.Inject;
+import br.ufrgs.inf.prosoft.cache.MultiCache;
+
import org.json.simple.JSONArray;
import org.json.simple.JSONValue;
import org.slf4j.Logger;
@@ -52,93 +54,98 @@ public class ModuleConfigurationServiceImpl extends
}
+public static MultiCache<String, List<IntegrationModule>> getIntegrationModulesCache = new MultiCache<>("getIntegrationModulesCache");
+
+
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public List<IntegrationModule> getIntegrationModules(String module) {
+ return getIntegrationModulesCache.computeIfAbsent("INTEGRATION_M)" + module, () -> {
- List<IntegrationModule> modules = null;
- try {
-
- //CacheUtils cacheUtils = CacheUtils.getInstance();
-// modules = (List<IntegrationModule>) cache.getFromCache("INTEGRATION_M)" + module);
- if(modules==null) {
- modules = moduleConfigurationRepository.findByModule(module);
- //set json objects
- for(IntegrationModule mod : modules) {
-
- String regions = mod.getRegions();
- if(regions!=null) {
- Object objRegions=JSONValue.parse(regions);
- JSONArray arrayRegions=(JSONArray)objRegions;
- Iterator i = arrayRegions.iterator();
- while(i.hasNext()) {
- mod.getRegionsSet().add((String)i.next());
+ List<IntegrationModule> modules = null;
+ try {
+
+ //CacheUtils cacheUtils = CacheUtils.getInstance();
+ // modules = (List<IntegrationModule>) cache.getFromCache("INTEGRATION_M)" + module);
+ if(modules==null) {
+ modules = moduleConfigurationRepository.findByModule(module);
+ //set json objects
+ for(IntegrationModule mod : modules) {
+
+ String regions = mod.getRegions();
+ if(regions!=null) {
+ Object objRegions=JSONValue.parse(regions);
+ JSONArray arrayRegions=(JSONArray)objRegions;
+ Iterator i = arrayRegions.iterator();
+ while(i.hasNext()) {
+ mod.getRegionsSet().add((String)i.next());
+ }
}
- }
-
-
- String details = mod.getConfigDetails();
- if(details!=null) {
- //Map objects = mapper.readValue(config, Map.class);
+
+ String details = mod.getConfigDetails();
+ if(details!=null) {
+
+ //Map objects = mapper.readValue(config, Map.class);
- Map<String,String> objDetails= (Map<String, String>) JSONValue.parse(details);
- mod.setDetails(objDetails);
+ Map<String,String> objDetails= (Map<String, String>) JSONValue.parse(details);
+ mod.setDetails(objDetails);
+
+ }
- }
-
-
- String configs = mod.getConfiguration();
- if(configs!=null) {
- //Map objects = mapper.readValue(config, Map.class);
+ String configs = mod.getConfiguration();
+ if(configs!=null) {
+
+ //Map objects = mapper.readValue(config, Map.class);
- Object objConfigs=JSONValue.parse(configs);
- JSONArray arrayConfigs=(JSONArray)objConfigs;
-
- Map<String,ModuleConfig> moduleConfigs = new HashMap<String,ModuleConfig>();
-
- Iterator i = arrayConfigs.iterator();
- while(i.hasNext()) {
+ Object objConfigs=JSONValue.parse(configs);
+ JSONArray arrayConfigs=(JSONArray)objConfigs;
- Map values = (Map)i.next();
- String env = (String)values.get("env");
- ModuleConfig config = new ModuleConfig();
- config.setScheme((String)values.get("scheme"));
- config.setHost((String)values.get("host"));
- config.setPort((String)values.get("port"));
- config.setUri((String)values.get("uri"));
- config.setEnv((String)values.get("env"));
- if((String)values.get("config1")!=null) {
- config.setConfig1((String)values.get("config1"));
- }
- if((String)values.get("config2")!=null) {
- config.setConfig1((String)values.get("config2"));
- }
-
- moduleConfigs.put(env, config);
-
-
+ Map<String,ModuleConfig> moduleConfigs = new HashMap<String,ModuleConfig>();
+
+ Iterator i = arrayConfigs.iterator();
+ while(i.hasNext()) {
+
+ Map values = (Map)i.next();
+ String env = (String)values.get("env");
+ ModuleConfig config = new ModuleConfig();
+ config.setScheme((String)values.get("scheme"));
+ config.setHost((String)values.get("host"));
+ config.setPort((String)values.get("port"));
+ config.setUri((String)values.get("uri"));
+ config.setEnv((String)values.get("env"));
+ if((String)values.get("config1")!=null) {
+ config.setConfig1((String)values.get("config1"));
+ }
+ if((String)values.get("config2")!=null) {
+ config.setConfig1((String)values.get("config2"));
+ }
+
+ moduleConfigs.put(env, config);
+
+
+
+ }
+
+ mod.setModuleConfigs(moduleConfigs);
- }
-
- mod.setModuleConfigs(moduleConfigs);
-
- }
+ }
+ }
+ // cache.putInCache(modules, "INTEGRATION_M)" + module);
}
-// cache.putInCache(modules, "INTEGRATION_M)" + module);
- }
- } catch (Exception e) {
- LOGGER.error("getIntegrationModules()", e);
- }
- return modules;
+ } catch (Exception e) {
+ LOGGER.error("getIntegrationModules()", e);
+ }
+ return modules;
+ }, 1200000);
}
sm-shop/pom.xml 52(+0 -52)
diff --git a/sm-shop/pom.xml b/sm-shop/pom.xml
index 9eb8ac0..d9321d1 100644
--- a/sm-shop/pom.xml
+++ b/sm-shop/pom.xml
@@ -159,57 +159,5 @@
</dependencies>
-
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>aspectj-maven-plugin</artifactId>
- <version>1.11</version>
- <configuration>
- <showWeaveInfo>false</showWeaveInfo>
- <complianceLevel>1.8</complianceLevel>
- <source>1.6</source>
- <target>1.6</target>
- <Xlint>ignore</Xlint>
- <encoding>UTF-8</encoding>
- <verbose>false</verbose>
- <forceAjcCompile>true</forceAjcCompile>
- <sources/>
- <weaveDirectories>
- <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
- </weaveDirectories>
- <aspectLibraries>
- <aspectLibrary>
- <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
- <artifactId>ApplicationTracer</artifactId>
- </aspectLibrary>
- </aspectLibraries>
- </configuration>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>1.9.1</version>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjtools</artifactId>
- <version>1.9.1</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
</project>
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/constants/Constants.java b/sm-shop/src/main/java/com/salesmanager/shop/constants/Constants.java
index 234a80c..c764639 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/constants/Constants.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/constants/Constants.java
@@ -77,11 +77,11 @@ public class Constants {
public final static String CONTENT_CACHE_KEY = "CONTENT";
public final static String CONTENT_PAGE_CACHE_KEY = "CONTENT_PAGE";
public final static String CATEGORIES_CACHE_KEY = "CATALOG_CATEGORIES";
- // public final static String PRODUCTS_GROUP_CACHE_KEY = "CATALOG_GROUP";
- // public final static String SUBCATEGORIES_CACHE_KEY = "CATALOG_SUBCATEGORIES";
- // public final static String RELATEDITEMS_CACHE_KEY = "CATALOG_RELATEDITEMS";
- // public final static String MANUFACTURERS_BY_PRODUCTS_CACHE_KEY = "CATALOG_BRANDS_BY_PRODUCTS";
- // public final static String CONFIG_CACHE_KEY = "CONFIG";
+ public final static String PRODUCTS_GROUP_CACHE_KEY = "CATALOG_GROUP";
+ public final static String SUBCATEGORIES_CACHE_KEY = "CATALOG_SUBCATEGORIES";
+ public final static String RELATEDITEMS_CACHE_KEY = "CATALOG_RELATEDITEMS";
+ public final static String MANUFACTURERS_BY_PRODUCTS_CACHE_KEY = "CATALOG_BRANDS_BY_PRODUCTS";
+ public final static String CONFIG_CACHE_KEY = "CONFIG";
public final static String REQUEST_CONTENT_OBJECTS = "CONTENT";
public final static String REQUEST_CONTENT_PAGE_OBJECTS = "CONTENT_PAGE";
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/controller/ReferenceController.java b/sm-shop/src/main/java/com/salesmanager/shop/controller/ReferenceController.java
index 794d9ab..03347a3 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/controller/ReferenceController.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/controller/ReferenceController.java
@@ -26,6 +26,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import br.ufrgs.inf.prosoft.cache.GetterCache;
+
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -166,6 +168,9 @@ public class ReferenceController {
return zoneCode;
}
+
+public static GetterCache<List<String>> getCreditCardYearsCache = new GetterCache<>("getCreditCardYearsCache");
+
@SuppressWarnings("unchecked")
@RequestMapping(value={"/shop/reference/creditCardDates.html"}, method=RequestMethod.GET)
public @ResponseBody ResponseEntity<String> getCreditCardDates(HttpServletRequest request, HttpServletResponse response) {
@@ -175,26 +180,25 @@ public class ReferenceController {
String serialized = null;
try {
-
-// years = (List<String>)cache.getFromCache(Constants.CREDIT_CARD_YEARS_CACHE_KEY);
-
- if(years==null) {
-
- years = new ArrayList<String>();
- //current year
-
- for(int i = 0 ; i < 10 ; i++) {
- Calendar localCalendar = Calendar.getInstance(TimeZone.getDefault());
- localCalendar.add(Calendar.YEAR, i);
- String dt = DateUtil.formatYear(localCalendar.getTime());
- years.add(dt);
- }
- //up to year + 10
-
-// cache.putInCache(years, Constants.CREDIT_CARD_YEARS_CACHE_KEY);
-
- }
-
+
+ years = getCreditCardYearsCache.computeIfAbsent(() -> {
+
+ // years = (List<String>)cache.getFromCache(Constants.CREDIT_CARD_YEARS_CACHE_KEY);
+
+ List<String> y = new ArrayList<String>();
+ //current year
+
+ for(int i = 0 ; i < 10 ; i++) {
+ Calendar localCalendar = Calendar.getInstance(TimeZone.getDefault());
+ localCalendar.add(Calendar.YEAR, i);
+ String dt = DateUtil.formatYear(localCalendar.getTime());
+ y.add(dt);
+ }
+ //up to year + 10
+
+ // cache.putInCache(years, Constants.CREDIT_CARD_YEARS_CACHE_KEY);
+ return y;
+ }, 1200000);
final ObjectMapper mapper = new ObjectMapper();
@@ -209,8 +213,9 @@ public class ReferenceController {
return new ResponseEntity<String>(serialized,httpHeaders,HttpStatus.OK);
}
-
-
+
+public static GetterCache<List<String>> getMonthsOfYearCache = new GetterCache<>("getMonthsOfYearCache");
+
@SuppressWarnings("unchecked")
@RequestMapping(value={"/shop/reference/monthsOfYear.html"}, method=RequestMethod.GET)
public @ResponseBody ResponseEntity<String> getMonthsOfYear(HttpServletRequest request, HttpServletResponse response) {
@@ -221,17 +226,19 @@ public class ReferenceController {
try {
// days = (List<String>)cache.getFromCache(Constants.MONTHS_OF_YEAR_CACHE_KEY);
- if(days==null) {
- days = new ArrayList<String>();
+ days = getMonthsOfYearCache.computeIfAbsent(() -> {
+
+ List<String> d = new ArrayList<String>();
for(int i = 1 ; i < 13 ; i++) {
- days.add(String.format("%02d", i));
+ d.add(String.format("%02d", i));
}
-// cache.putInCache(days, Constants.MONTHS_OF_YEAR_CACHE_KEY);
-
- }
-
+ // cache.putInCache(days, Constants.MONTHS_OF_YEAR_CACHE_KEY);
+
+ return d;
+
+ }, 1200000);
final ObjectMapper mapper = new ObjectMapper();
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/filter/AdminFilter.java b/sm-shop/src/main/java/com/salesmanager/shop/filter/AdminFilter.java
index cbb5aca..5a730ed 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/filter/AdminFilter.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/filter/AdminFilter.java
@@ -14,6 +14,7 @@ import com.salesmanager.shop.admin.model.web.Menu;
import com.salesmanager.shop.constants.Constants;
import com.salesmanager.shop.utils.LanguageUtils;
+import br.ufrgs.inf.prosoft.cache.GetterCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,6 +52,8 @@ public class AdminFilter extends HandlerInterceptorAdapter {
@Inject
private LanguageUtils languageUtils;
+public static GetterCache<Map<String,Menu>> menuMapCache = new GetterCache<>("menuMapCache");
+
public boolean preHandle(
HttpServletRequest request,
HttpServletResponse response,
@@ -135,43 +138,44 @@ public class AdminFilter extends HandlerInterceptorAdapter {
request.setAttribute(Constants.LANGUAGE, language);
- if(menus==null) {
- InputStream in = null;
- ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally
- try {
- in =
- (InputStream) this.getClass().getClassLoader().getResourceAsStream("admin/menu.json");
+ menus = menuMapCache.computeIfAbsent(() -> {
+ InputStream in = null;
+ ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally
+ Map<String,Menu> ms = null;
+ try {
+ in =
+ (InputStream) this.getClass().getClassLoader().getResourceAsStream("admin/menu.json");
- Map<String,Object> data = mapper.readValue(in, Map.class);
+ Map<String,Object> data = mapper.readValue(in, Map.class);
- Menu currentMenu = null;
-
- menus = new LinkedHashMap<String,Menu>();
- List objects = (List)data.get("menus");
- for(Object object : objects) {
- Menu m = getMenu(object);
- menus.put(m.getCode(),m);
- }
+ Menu currentMenu = null;
+
+ ms = new LinkedHashMap<String,Menu>();
+ List objects = (List)data.get("menus");
+ for(Object object : objects) {
+ Menu m = getMenu(object);
+ ms.put(m.getCode(),m);
+ }
-// cache.putInCache(menus,"MENUMAP");
-
- } catch (JsonParseException e) {
- LOGGER.error("Error while creating menu", e);
- } catch (JsonMappingException e) {
- LOGGER.error("Error while creating menu", e);
- } catch (IOException e) {
- LOGGER.error("Error while creating menu", e);
- } finally {
- if(in !=null) {
- try {
- in.close();
- } catch (Exception ignore) {
- // TODO: handle exception
+ // cache.putInCache(menus,"MENUMAP");
+
+ } catch (JsonParseException e) {
+ LOGGER.error("Error while creating menu", e);
+ } catch (JsonMappingException e) {
+ LOGGER.error("Error while creating menu", e);
+ } catch (IOException e) {
+ LOGGER.error("Error while creating menu", e);
+ } finally {
+ if(in !=null) {
+ try {
+ in.close();
+ } catch (Exception ignore) {
+ // TODO: handle exception
+ }
}
}
- }
-
- }
+ return ms;
+ }, 1200000);
List<Menu> list = new ArrayList<Menu>(menus.values());
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/filter/StoreFilter.java b/sm-shop/src/main/java/com/salesmanager/shop/filter/StoreFilter.java
index a26158d..1cd880c 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/filter/StoreFilter.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/filter/StoreFilter.java
@@ -45,6 +45,8 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+import br.ufrgs.inf.prosoft.cache.MultiCache;
+
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -368,16 +370,18 @@ public class StoreFilter extends HandlerInterceptorAdapter {
}
+public static MultiCache<String, Map<String, Object>> getConfigurationsCache = new MultiCache<>("getConfigurationsCache");
+
@SuppressWarnings("unchecked")
private void getMerchantConfigurations(MerchantStore store, HttpServletRequest request) throws Exception {
- // StringBuilder configKey = new StringBuilder();
- // configKey
- // .append(store.getId())
- // .append("_")
- // .append(Constants.CONFIG_CACHE_KEY);
+ StringBuilder configKey = new StringBuilder();
+ configKey
+ .append(store.getId())
+ .append("_")
+ .append(Constants.CONFIG_CACHE_KEY);
// StringBuilder configKeyMissed = new StringBuilder();
@@ -391,22 +395,24 @@ public class StoreFilter extends HandlerInterceptorAdapter {
//get from the cache
// configs = (Map<String, Object>) cache.getFromCache(configKey.toString());
- if(configs==null) {
+ // if(configs==null) {
//get from missed cache
//Boolean missedContent = (Boolean)cache.getFromCache(configKeyMissed.toString());
//if( missedContent==null) {
- configs = this.getConfigurations(store);
+ configs = getConfigurationsCache.computeIfAbsent(configKey.toString(), () -> {
+ return this.getConfigurations(store);
+ }, 1200000);
//put in cache
- if(configs!=null) {
+ // if(configs!=null) {
// cache.putInCache(configs, configKey.toString());
- } else {
+ // } else {
//put in missed cache
//cache.putInCache(new Boolean(true), configKeyMissed.toString());
- }
+ // }
//}
- }
+ // }
} else {
configs = this.getConfigurations(store);
@@ -421,6 +427,8 @@ public class StoreFilter extends HandlerInterceptorAdapter {
}
+public static MultiCache<String, Map<String, List<ContentDescription>>> getContentPageNamesCache = new MultiCache<>("getContentPageNamesCache");
+
@SuppressWarnings("unchecked")
private void getContentPageNames(MerchantStore store, Language language, HttpServletRequest request) throws Exception {
@@ -460,25 +468,30 @@ public class StoreFilter extends HandlerInterceptorAdapter {
// contents = (Map<String, List<ContentDescription>>) cache.getFromCache(contentKey.toString());
- if(contents==null) {
+ // if(contents==null) {
//get from missed cache
//Boolean missedContent = (Boolean)cache.getFromCache(contentKeyMissed.toString());
//if(missedContent==null) {
-
- contents = this.getContentPagesNames(store, language);
+ contents = getContentPageNamesCache.computeIfAbsent(contentKey.toString(), () -> {
+ try {
+ return this.getContentPagesNames(store, language);
+ } catch (Exception ex) {
+ return null;
+ }
+ }, 1200000);
- if(contents!=null) {
+ // if(contents!=null) {
//put in cache
// cache.putInCache(contents, contentKey.toString());
- } else {
+ // } else {
//put in missed cache
- //cache.putInCache(new Boolean(true), contentKeyMissed.toString());
- }
+ // cache.putInCache(new Boolean(true), contentKeyMissed.toString());
+ // }
//}
- }
+ // }
} else {
contents = this.getContentPagesNames(store, language);
}
@@ -493,6 +506,8 @@ public class StoreFilter extends HandlerInterceptorAdapter {
}
}
+public static MultiCache<String, Map<String, List<Content>>> getContentObjectsCache = new MultiCache<>("getContentObjectsCache");
+
@SuppressWarnings({ "unchecked"})
private void getContentObjects(MerchantStore store, Language language, HttpServletRequest request) throws Exception {
@@ -532,25 +547,30 @@ public class StoreFilter extends HandlerInterceptorAdapter {
// contents = (Map<String, List<Content>>) cache.getFromCache(contentKey.toString());
- if(contents==null) {
+ // if(contents==null) {
//get from missed cache
//Boolean missedContent = (Boolean)cache.getFromCache(contentKeyMissed.toString());
//if(missedContent==null) {
-
- contents = this.getContent(store, language);
- if(contents!=null && contents.size()>0) {
+ contents = getContentObjectsCache.computeIfAbsent(contentKey.toString(), () -> {
+ try {
+ return this.getContent(store, language);
+ } catch (Exception ex) {
+ return null;
+ }
+ }, 1200000);
+ // if(contents!=null && contents.size()>0) {
//put in cache
// cache.putInCache(contents, contentKey.toString());
- } else {
+ // } else {
//put in missed cache
//cache.putInCache(new Boolean(true), contentKeyMissed.toString());
- }
+ // }
//}
- }
+ // }
} else {
contents = this.getContent(store, language);
@@ -579,17 +599,19 @@ public class StoreFilter extends HandlerInterceptorAdapter {
}
-
+
+public static MultiCache<String, Map<String, List<ReadableCategory>>> getTopCategoriesCache = new MultiCache<>("getTopCategoriesCache");
+
@SuppressWarnings("unchecked")
private void setTopCategories(MerchantStore store, Language language, HttpServletRequest request) throws Exception {
- // StringBuilder categoriesKey = new StringBuilder();
- // categoriesKey
- // .append(store.getId())
- // .append("_")
- // .append(Constants.CATEGORIES_CACHE_KEY)
- // .append("-")
- // .append(language.getCode());
+ StringBuilder categoriesKey = new StringBuilder();
+ categoriesKey
+ .append(store.getId())
+ .append("_")
+ .append(Constants.CATEGORIES_CACHE_KEY)
+ .append("-")
+ .append(language.getCode());
// StringBuilder categoriesKeyMissed = new StringBuilder();
// categoriesKeyMissed
@@ -604,16 +626,23 @@ public class StoreFilter extends HandlerInterceptorAdapter {
if(store.isUseCache()) {
// objects = (Map<String, List<ReadableCategory>>) webApplicationCache.getFromCache(categoriesKey.toString());
- if(objects==null) {
+ // if(objects==null) {
//load categories
- loadedCategories = categoryFacade.getCategoryHierarchy(store, 0, language);
- objects = new ConcurrentHashMap<String, List<ReadableCategory>>();
- objects.put(language.getCode(), loadedCategories);
+ objects = getTopCategoriesCache.computeIfAbsent(categoriesKey.toString(), () -> {
+ try {
+ List<ReadableCategory> l = categoryFacade.getCategoryHierarchy(store, 0, language);
+ Map<String, List<ReadableCategory>> o = new ConcurrentHashMap<String, List<ReadableCategory>>();
+ o.put(language.getCode(), l);
+ return o;
+ } catch (Exception ex) {
+ return new HashMap<String, List<ReadableCategory>>();
+ }
+ }, 1200000);
// webApplicationCache.putInCache(categoriesKey.toString(), objects);
- } else {
+ // } else {
loadedCategories = objects.get(language.getCode());
- }
+ // }
} else {
loadedCategories = categoryFacade.getCategoryHierarchy(store, 0, language);
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java
index d0559a8..4c6ba20 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java
@@ -40,6 +40,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
+import br.ufrgs.inf.prosoft.cache.MultiCache;
+
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -131,6 +133,8 @@ public class ShoppingCategoryController {
return this.displayCategory(friendlyUrl,null,model,request,response,locale);
}
+public static MultiCache<String, List<ReadableCategory>> getCategoriesCache = new MultiCache<>("getCategoriesCache");
+
@SuppressWarnings("unchecked")
private String displayCategory(final String friendlyUrl, final String ref, Model model, HttpServletRequest request, HttpServletResponse response, Locale locale) throws Exception {
@@ -190,15 +194,15 @@ public class ShoppingCategoryController {
subIds.add(category.getId());
-// StringBuilder subCategoriesCacheKey = new StringBuilder();
-// subCategoriesCacheKey
-// .append(store.getId())
-// .append("_")
-// .append(category.getId())
-// .append("_")
-// .append(Constants.SUBCATEGORIES_CACHE_KEY)
-// .append("-")
-// .append(language.getCode());
+ StringBuilder subCategoriesCacheKey = new StringBuilder();
+ subCategoriesCacheKey
+ .append(store.getId())
+ .append("_")
+ .append(category.getId())
+ .append("_")
+ .append(Constants.SUBCATEGORIES_CACHE_KEY)
+ .append("-")
+ .append(language.getCode());
// StringBuilder subCategoriesMissed = new StringBuilder();
// subCategoriesMissed
@@ -211,23 +215,31 @@ public class ShoppingCategoryController {
if(store.isUseCache()) {
+
//get from the cache
// subCategories = (List<ReadableCategory>) cache.getFromCache(subCategoriesCacheKey.toString());
- if(subCategories==null) {
+ // if(subCategories==null) {
//get from missed cache
//Boolean missedContent = (Boolean)cache.getFromCache(subCategoriesMissed.toString());
//if(missedContent==null) {
- countProductsByCategories = getProductsByCategory(store, category, lineage, subIds);
- subCategories = getSubCategories(store,category,countProductsByCategories,language,locale);
+
+ subCategories = getCategoriesCache.computeIfAbsent(subCategoriesCacheKey.toString(), () -> {
+ try {
+ Map<Long,Long> p = getProductsByCategory(store, category, lineage, subIds);
+ return getSubCategories(store,category,p,language,locale);
+ } catch (Exception ex){
+ return null;
+ }
+ }, 1200000);
- if(subCategories!=null) {
+ // if(subCategories!=null) {
// cache.putInCache(subCategories, subCategoriesCacheKey.toString());
- } else {
+ // } else {
//cache.putInCache(new Boolean(true), subCategoriesCacheKey.toString());
- }
+ // }
//}
- }
+ // }
} else {
countProductsByCategories = getProductsByCategory(store, category, lineage, subIds);
subCategories = getSubCategories(store,category,countProductsByCategories,language,locale);
@@ -261,6 +273,8 @@ public class ShoppingCategoryController {
return template.toString();
}
+public static MultiCache<String, List<ReadableManufacturer>> getManufacturersCache = new MultiCache<>("getManufacturersCache");
+
@SuppressWarnings("unchecked")
private List<ReadableManufacturer> getManufacturersByProductAndCategory(MerchantStore store, Category category, List<Long> subCategoryIds, Language language) throws Exception {
@@ -268,13 +282,13 @@ public class ShoppingCategoryController {
/** List of manufacturers **/
if(subCategoryIds!=null && subCategoryIds.size()>0) {
-// StringBuilder manufacturersKey = new StringBuilder();
-// manufacturersKey
-// .append(store.getId())
-// .append("_")
-// .append(Constants.MANUFACTURERS_BY_PRODUCTS_CACHE_KEY)
-// .append("-")
-// .append(language.getCode());
+ StringBuilder manufacturersKey = new StringBuilder();
+ manufacturersKey
+ .append(store.getId())
+ .append("_")
+ .append(Constants.MANUFACTURERS_BY_PRODUCTS_CACHE_KEY)
+ .append("-")
+ .append(language.getCode());
// StringBuilder manufacturersKeyMissed = new StringBuilder();
// manufacturersKeyMissed
@@ -288,18 +302,24 @@ public class ShoppingCategoryController {
// manufacturerList = (List<ReadableManufacturer>) cache.getFromCache(manufacturersKey.toString());
- if(manufacturerList==null) {
+ // if(manufacturerList==null) {
//get from missed cache
//Boolean missedContent = (Boolean)cache.getFromCache(manufacturersKeyMissed.toString());
//if(missedContent==null) {
- manufacturerList = this.getManufacturers(store, subCategoryIds, language);
- if(manufacturerList.isEmpty()) {
+ manufacturerList = getManufacturersCache.computeIfAbsent(manufacturersKey.toString(), () -> {
+ try {
+ return this.getManufacturers(store, subCategoryIds, language);
+ } catch (Exception ex){
+ return null;
+ }
+ }, 1200000);
+ // if(manufacturerList.isEmpty()) {
// cache.putInCache(new Boolean(true), manufacturersKeyMissed.toString());
- } else {
+ // } else {
//cache.putInCache(manufacturerList, manufacturersKey.toString());
- }
+ // }
//}
- }
+ // }
} else {
manufacturerList = this.getManufacturers(store, subCategoryIds, language);
}
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/product/ShopProductController.java b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/product/ShopProductController.java
index fc6c97a..2eb3c77 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/product/ShopProductController.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/product/ShopProductController.java
@@ -43,6 +43,8 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
+import br.ufrgs.inf.prosoft.cache.MultiCache;
+
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -126,6 +128,9 @@ public class ShopProductController {
}
+public static MultiCache<String, Map<Long,List<ReadableProduct>>> getRelatedItemsCache = new MultiCache<>("getRelatedItemsCache");
+
+
public String display(final String reference, final String friendlyUrl, Model model, HttpServletRequest request, HttpServletResponse response, Locale locale) throws Exception {
@@ -159,13 +164,13 @@ public class ShopProductController {
-// StringBuilder relatedItemsCacheKey = new StringBuilder();
-// relatedItemsCacheKey
-// .append(store.getId())
-// .append("_")
-// .append(Constants.RELATEDITEMS_CACHE_KEY)
-// .append("-")
-// .append(language.getCode());
+ StringBuilder relatedItemsCacheKey = new StringBuilder();
+ relatedItemsCacheKey
+ .append(store.getId())
+ .append("_")
+ .append(Constants.RELATEDITEMS_CACHE_KEY)
+ .append("-")
+ .append(language.getCode());
// StringBuilder relatedItemsMissed = new StringBuilder();
// relatedItemsMissed
@@ -177,25 +182,34 @@ public class ShopProductController {
if(store.isUseCache()) {
+
+
//get from the cache
// relatedItemsMap = (Map<Long,List<ReadableProduct>>) cache.getFromCache(relatedItemsCacheKey.toString());
- if(relatedItemsMap==null) {
+ // if(relatedItemsMap==null) {
//get from missed cache
//Boolean missedContent = (Boolean)cache.getFromCache(relatedItemsMissed.toString());
//if(missedContent==null) {
- relatedItems = relatedItems(store, product, language);
- if(relatedItems!=null) {
-// relatedItemsMap = new HashMap<Long,List<ReadableProduct>>();
-// relatedItemsMap.put(product.getId(), relatedItems);
+ // if(relatedItems!=null) {
+ relatedItemsMap = getRelatedItemsCache.computeIfAbsent(relatedItemsCacheKey.toString(), () -> {
+ try {
+ List<ReadableProduct> r = relatedItems(store, product, language);
+ Map<Long,List<ReadableProduct>> m = new HashMap<Long,List<ReadableProduct>>();
+ m.put(product.getId(), r);
+ return m;
+ } catch (Exception ex) {
+ return new HashMap<Long,List<ReadableProduct>>();
+ }
+ }, 1200000);
// cache.putInCache(relatedItemsMap, relatedItemsCacheKey.toString());
- } else {
+ // } else {
//cache.putInCache(new Boolean(true), relatedItemsMissed.toString());
- }
+ // }
//}
- } else {
+ // } else {
relatedItems = relatedItemsMap.get(product.getId());
- }
+ // }
} else {
relatedItems = relatedItems(store, product, language);
}
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/tags/ShopProductRelationshipTag.java b/sm-shop/src/main/java/com/salesmanager/shop/tags/ShopProductRelationshipTag.java
index 0f978d2..bdbed26 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/tags/ShopProductRelationshipTag.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/tags/ShopProductRelationshipTag.java
@@ -6,6 +6,8 @@ import java.util.List;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
+import br.ufrgs.inf.prosoft.cache.MultiCache;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -65,6 +67,7 @@ public class ShopProductRelationshipTag extends RequestContextAwareTag {
this.groupName = groupName;
}
+public static MultiCache<String, List<ReadableProduct>> getReadableProductsCache = new MultiCache<>("getReadableProductsCache");
@SuppressWarnings("unchecked")
@Override
@@ -81,41 +84,49 @@ public class ShopProductRelationshipTag extends RequestContextAwareTag {
MerchantStore store = (MerchantStore)request.getAttribute(Constants.MERCHANT_STORE);
-// Language language = (Language)request.getAttribute(Constants.LANGUAGE);
-
-// StringBuilder groupKey = new StringBuilder();
-// groupKey
-// .append(store.getId())
-// .append("_")
-// .append(Constants.PRODUCTS_GROUP_CACHE_KEY)
-// .append("-")
-// .append(this.getGroupName())
-// .append("_")
-// .append(language.getCode());
+ Language language = (Language)request.getAttribute(Constants.LANGUAGE);
+
+ StringBuilder groupKey = new StringBuilder();
+ groupKey
+ .append(store.getId())
+ .append("_")
+ .append(Constants.PRODUCTS_GROUP_CACHE_KEY)
+ .append("-")
+ .append(this.getGroupName())
+ .append("_")
+ .append(language.getCode());
-// StringBuilder groupKeyMissed = new StringBuilder();
-// groupKeyMissed
-// .append(groupKey.toString())
-// .append(Constants.MISSED_CACHE_KEY);
+ // StringBuilder groupKeyMissed = new StringBuilder();
+ // groupKeyMissed
+ // .append(groupKey.toString())
+ // .append(Constants.MISSED_CACHE_KEY);
List<ReadableProduct> objects = null;
if(store.isUseCache()) {
//get from the cache
-// objects = (List<ReadableProduct>) cache.getFromCache(groupKey.toString());
- Boolean missedContent = null;
+ // objects = (List<ReadableProduct>) cache.getFromCache(groupKey.toString());
+ objects = getReadableProductsCache.computeIfAbsent(groupKey.toString(), () -> {
+ try {
+ return getProducts(request);
+ } catch (Exception ex) {
+ return null;
+ }
+ }, 1200000);
+
+ // Boolean missedContent = null;
- if(objects==null && missedContent==null) {
- objects = getProducts(request);
+ // if(objects==null && missedContent==null) {
+ // objects = getProducts(request);
//put in cache
// cache.putInCache(objects, groupKey.toString());
- } else {
+ // } else {
//put in missed cache
- //cache.putInCache(new Boolean(true), groupKeyMissed.toString());
- }
+ // cache.putInCache(new Boolean(true), groupKeyMissed.toString());
+ // }
} else {
objects = getProducts(request);