Commit 7ca66193 authored by Matija Obreza's avatar Matija Obreza
Browse files

Synchronized PDCI stats #2

parent 2e166a85
......@@ -108,6 +108,7 @@ import org.genesys2.util.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
......@@ -1682,7 +1683,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
}
@Override
public PDCIStatistics statisticsPDCI(FaoInstitute faoInstitute) {
@Cacheable(unless = "#result == null", value = "statistics", key = "'stats.' + #root.methodName + '-' + #faoInstitute.id")
public synchronized PDCIStatistics statisticsPDCI(FaoInstitute faoInstitute) {
PDCIStatistics stats = new PDCIStatistics();
Object[] overall = (Object[]) repoPdci.statistics(faoInstitute);
......
......@@ -62,7 +62,7 @@ public class StatisticsServiceImpl implements StatisticsService {
public long numberOfAccessions() {
return genesysService.countAll();
}
@Override
@Cacheable(value = "statistics", key = "'stats.' + #root.methodName")
public long numberOfActiveAccessions() {
......@@ -78,12 +78,10 @@ public class StatisticsServiceImpl implements StatisticsService {
@Override
@Cacheable(unless = "#result == null", value = "statistics", key = "'stats.' + #root.methodName + '-' + #faoInstitute.id")
public PDCIStatistics statisticsPDCI(FaoInstitute faoInstitute) {
synchronized (this) {
if (LOG.isDebugEnabled()) {
LOG.debug("Regenerating PDCI statistics for " + faoInstitute);
}
return genesysService.statisticsPDCI(faoInstitute);
if (LOG.isDebugEnabled()) {
LOG.debug("Regenerating PDCI statistics for " + faoInstitute);
}
return genesysService.statisticsPDCI(faoInstitute);
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment