use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.
the class SeoTagsServiceImpl method getNewsSeoTags.
@Override
@Cacheable(value = "seo-github-news")
public SeoTags getNewsSeoTags(String url) {
String[] urlElements = RelativeUrlUtils.getPathElements(url);
List<NextProtNews> allNews = gitHubService.getNews();
if (urlElements.length > 1) {
String pageUrl = urlElements[1];
for (NextProtNews oneNews : allNews) {
if (pageUrl.equals(oneNews.getUrl())) {
return getOneNewsSeoTags(oneNews);
}
}
} else {
NextProtNews mostRecentNews = allNews.get(allNews.size() - 1);
return getOneNewsSeoTags(mostRecentNews);
}
return null;
}
use of org.springframework.cache.annotation.Cacheable in project cloudbreak by hortonworks.
the class ResourceDefinitionService method getResourceDefinition.
@Cacheable("resourceDefinitionCache")
public String getResourceDefinition(String cloudPlatform, String resource) {
LOGGER.debug("Sending request for {} {} resource property definition", cloudPlatform, resource);
CloudPlatformVariant platformVariant = new CloudPlatformVariant(Platform.platform(cloudPlatform), Variant.EMPTY);
ResourceDefinitionRequest request = new ResourceDefinitionRequest(platformVariant, resource);
eventBus.notify(request.selector(), eventFactory.createEvent(request));
try {
ResourceDefinitionResult result = request.await();
LOGGER.info("Resource property definition: {}", result);
return result.getDefinition();
} catch (InterruptedException e) {
LOGGER.error("Error while sending resource definition request", e);
throw new OperationException(e);
}
}
use of org.springframework.cache.annotation.Cacheable in project goci by EBISPOT.
the class DiseaseTraitService method similaritySearch.
@Cacheable(value = "diseaseTraitAnalysis", key = "#analysisId")
public AnalysisCacheDto similaritySearch(List<AnalysisDTO> diseaseTraitAnalysisDTOS, String analysisId, double threshold) {
LevenshteinDistance lv = new LevenshteinDistance();
CosineDistance cd = new CosineDistance();
List<DiseaseTrait> diseaseTraits = diseaseTraitRepository.findAll();
List<AnalysisDTO> analysisReport = new ArrayList<>();
diseaseTraitAnalysisDTOS.forEach(diseaseTraitAnalysisDTO -> diseaseTraits.forEach(diseaseTrait -> {
String trait = diseaseTrait.getTrait();
String userTerm = diseaseTraitAnalysisDTO.getUserTerm();
double cosineDistance = cd.apply(userTerm, trait);
double levenshteinDistance = ((double) lv.apply(userTerm, trait)) / Math.max(userTerm.length(), trait.length());
double cosineSimilarityPercent = Math.round((1 - cosineDistance) * 100);
double levenshteinSimilarityPercent = Math.round((1 - levenshteinDistance) * 100);
double chosen = Math.max(cosineSimilarityPercent, levenshteinSimilarityPercent);
if (chosen >= threshold) {
AnalysisDTO report = AnalysisDTO.builder().userTerm(userTerm).similarTerm(trait).degree(chosen).build();
analysisReport.add(report);
}
}));
return AnalysisCacheDto.builder().uniqueId(analysisId).analysisResult(analysisReport).build();
}
use of org.springframework.cache.annotation.Cacheable in project pinpoint by naver.
the class ApplicationCache method findApplicationId.
@Cacheable(cacheNames = "applicationId", key = SPEL_KEY, cacheManager = FlinkCacheConfiguration.APPLICATION_ID_CACHE_NAME)
public String findApplicationId(ApplicationKey application) {
final String agentId = application.getAgentId();
final long agentStartTimestamp = application.getAgentStartTime();
final byte[] rowKey = rowKeyEncoder.encodeRowKey(agentId, agentStartTimestamp);
Get get = new Get(rowKey);
get.addColumn(AGENTINFO_INFO.getName(), AGENTINFO_INFO.QUALIFIER_IDENTIFIER);
AgentInfo agentInfo = null;
try {
TableName tableName = tableNameProvider.getTableName(AGENTINFO_INFO.getTable());
agentInfo = hbaseTemplate2.get(tableName, get, agentInfoMapper);
} catch (Exception e) {
logger.error("can't found application id({}). {}", agentId, e.getMessage());
}
return getApplicationId(agentInfo, agentId);
}
use of org.springframework.cache.annotation.Cacheable in project disconf by knightliao.
the class RoleResourceMgrImpl method getAllAsMap.
/**
* @return
*/
@Override
@Cacheable(value = "${role_res_cache_name}")
public Map<String, Map<RequestMethod, List<Integer>>> getAllAsMap() {
Map<String, Map<RequestMethod, List<Integer>>> infoMap = new HashMap<String, Map<RequestMethod, List<Integer>>>();
LOG.info("Querying role_resource table to get all...");
List<RoleResource> roleResList = roleResDao.findAll();
// 遍历列表,把数据按<url, <method, List<roleId>>>的形式加到infoMap
for (RoleResource roleRes : roleResList) {
String urlPattern = roleRes.getUrlPattern();
if (!urlPattern.endsWith(RoleResourceConstant.URL_SPLITOR)) {
urlPattern += RoleResourceConstant.URL_SPLITOR;
}
// LOG.info(urlPattern);
Map<RequestMethod, List<Integer>> value = infoMap.get(urlPattern);
if (value == null) {
value = new HashMap<RequestMethod, List<Integer>>();
infoMap.put(urlPattern, value);
}
updateMethodMap(value, roleRes.getRoleId(), roleRes.getMethodMask());
}
return infoMap;
}
Aggregations