debug:并发情况下,缓存多存很多信息
This commit is contained in:
parent
2f0a51b5c8
commit
130a4a6cbf
|
@ -78,9 +78,9 @@ public class AttachClassifyServiceImpl implements AttachClassifyService
|
|||
} else {
|
||||
attachClassify.setAncestors("0");
|
||||
}
|
||||
|
||||
|
||||
attachClassify.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
|
||||
return transactionTemplate.execute(status -> {
|
||||
int insert = attachClassifyMapper.insertAttachClassify(attachClassify);
|
||||
if (insert > 0) {
|
||||
|
@ -103,18 +103,18 @@ public class AttachClassifyServiceImpl implements AttachClassifyService
|
|||
AttachClassifyVO newParentClassify = attachClassifyMapper.selectAttachClassifyById(attachClassify.getParentId());
|
||||
// 查询旧的分类信息
|
||||
AttachClassifyVO oldClassify = attachClassifyMapper.selectAttachClassifyById(attachClassify.getId());
|
||||
|
||||
|
||||
return transactionTemplate.execute(status -> {
|
||||
if (newParentClassify != null && oldClassify != null) {
|
||||
// 构建新的祖级列表
|
||||
String newAncestors = newParentClassify.getAncestors() + "," + newParentClassify.getId();
|
||||
String oldAncestors = oldClassify.getAncestors();
|
||||
attachClassify.setAncestors(newAncestors);
|
||||
|
||||
|
||||
// 更新子节点的祖级列表
|
||||
updateChildrenAncestors(attachClassify.getId(), newAncestors, oldAncestors);
|
||||
}
|
||||
|
||||
|
||||
int update = attachClassifyMapper.updateAttachClassify(attachClassify);
|
||||
if (update > 0) {
|
||||
clearCache();
|
||||
|
@ -178,7 +178,7 @@ public class AttachClassifyServiceImpl implements AttachClassifyService
|
|||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
private int selectCountByParentIds(List<Long> parentIds) {
|
||||
private int selectCountByParentIds(List<Long> parentIds) {
|
||||
if (CollectionUtils.isEmptyElement(parentIds)) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -194,12 +194,12 @@ public class AttachClassifyServiceImpl implements AttachClassifyService
|
|||
|
||||
@Override
|
||||
public List<AttachClassifyNameVO> selectAllNameList(){
|
||||
List<AttachClassifyNameVO> list = redisCache.getCacheList(CacheConstants.ATTACH_CLASSIFY_NAME_LIST);
|
||||
List<AttachClassifyNameVO> list = redisCache.getCacheObject(CacheConstants.ATTACH_CLASSIFY_NAME_LIST);
|
||||
if(CollectionUtils.isEmptyElement(list)){
|
||||
PageHelper.orderBy("bac.sort asc");
|
||||
list = attachClassifyMapper.selectNameList(new AttachClassifyQuery());
|
||||
if (CollectionUtils.isNotEmptyElement(list)) {
|
||||
redisCache.setCacheList(CacheConstants.ATTACH_CLASSIFY_NAME_LIST, list);
|
||||
redisCache.setCacheObject(CacheConstants.ATTACH_CLASSIFY_NAME_LIST, list);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -142,11 +142,11 @@ public class ProjectServiceImpl implements ProjectService
|
|||
|
||||
@Override
|
||||
public List<ProjectNameVO> selectAllNameList() {
|
||||
List<ProjectNameVO> list = redisCache.getCacheList(CacheConstants.PROJECT_NAME_LIST);
|
||||
List<ProjectNameVO> list = redisCache.getCacheObject(CacheConstants.PROJECT_NAME_LIST);
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
list = projectMapper.selectNameList(new ProjectQuery());
|
||||
if (CollectionUtils.isNotEmptyElement(list)) {
|
||||
redisCache.setCacheList(CacheConstants.PROJECT_NAME_LIST, list);
|
||||
redisCache.setCacheObject(CacheConstants.PROJECT_NAME_LIST, list);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -302,7 +302,7 @@ public class UserServiceImpl implements UserService
|
|||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
void clearCache() {
|
||||
void clearCache() {
|
||||
redisCache.deleteObject(CacheConstants.USER_NAME_LIST);
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ public class UserServiceImpl implements UserService
|
|||
public boolean updateUserAvatar(String userName, String avatar)
|
||||
{
|
||||
int rows = userMapper.updateUserAvatar(userName, avatar);
|
||||
|
||||
|
||||
if (rows > 0) {
|
||||
clearCache();
|
||||
}
|
||||
|
@ -722,13 +722,13 @@ public class UserServiceImpl implements UserService
|
|||
|
||||
@Override
|
||||
public List<SysUserNameVO> selectAllUserNameList() {
|
||||
List<SysUserNameVO> list = redisCache.getCacheList(CacheConstants.USER_NAME_LIST);
|
||||
List<SysUserNameVO> list = redisCache.getCacheObject(CacheConstants.USER_NAME_LIST);
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
SysUserQuery query = new SysUserQuery();
|
||||
query.setExcludeUserId(1L);
|
||||
list = userMapper.selectNameList(query);
|
||||
if (CollectionUtils.isNotEmptyElement(list)) {
|
||||
redisCache.setCacheList(CacheConstants.USER_NAME_LIST, list);
|
||||
redisCache.setCacheObject(CacheConstants.USER_NAME_LIST, list);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
Loading…
Reference in New Issue
Block a user