/**
* 定时执行同步查看数
*/
@Scheduled(cron = “0 0/1 * * * ?”) //每35分钟
public void SynchronizationViewingnum(){
Set<String> keys = redisTemplate.keys(CacheName.StandardLibrary.getValue() +"Viewingnum:" + "*");
for (String key : keys) {
Integer value = redisService.getCacheObject(key);
int lastIndex = key.lastIndexOf(":");
String id = key.substring(lastIndex + 1);
StandardLibrary standardLibrary = new StandardLibrary();
standardLibrary.setId(Long.parseLong(id));
standardLibrary.setViewingNum(Integer.valueOf(value));
boolean update = standardLibraryService.updateById(standardLibrary);
log.info("同步标准库访问次数"+update);
}
}