提交 d86e600a 编写于 作者: sq3536's avatar sq3536

直接内存代替缓存

上级 8a95b275
......@@ -18,19 +18,24 @@ import java.util.*;
public class OUModelService
{
@Autowired
private IIBZOrganizationService iibzOrganizationService;
@Autowired
private IIBZDepartmentService iibzDepartmentService;
@Cacheable( value="ibzou-model",key = "'orgmap'")
public synchronized Map<String, Map<String, Set<String>>> getOrgModel()
private Map<String, Map<String, Set<String>>> orgmap=null;
private Object lockOrg=new Object();
//@Cacheable( value="ibzou-model",key = "'orgmap'")
public Map<String, Map<String, Set<String>>> getOrgModel()
{
if(orgmap!=null)
return orgmap;
synchronized(lockOrg)
{
if(orgmap!=null)
return orgmap;
Map<String, Map<String, Set<String>>> store=new LinkedHashMap<>();
Map<String, IBZOrganization> orgset=new LinkedHashMap<>();
List<IBZOrganization> listOrg=iibzOrganizationService.list();
......@@ -62,7 +67,10 @@ public class OUModelService
}
}
return store;
orgmap=store;
}
return orgmap;
}
public void loopOrg(IBZOrganization org,Map<String, IBZOrganization> orgset,Map<String, Map<String, Set<String>>> store)
......@@ -79,9 +87,20 @@ public class OUModelService
}
@Cacheable( value="ibzou-model",key = "'deptmap'")
public synchronized Map<String, Map<String, Set<String>>> getDeptModel(Map<String, Map<String, Set<String>>> orgstore)
private Map<String, Map<String, Set<String>>> deptmap=null;
private Object lockDept=new Object();
//@Cacheable( value="ibzou-model",key = "'deptmap'")
public Map<String, Map<String, Set<String>>> getDeptModel(Map<String, Map<String, Set<String>>> orgstore)
{
if(deptmap!=null)
return deptmap;
synchronized(lockDept)
{
if(deptmap!=null)
return deptmap;
if(orgstore==null)
orgstore=this.getOrgModel();
Map<String, Map<String, Set<String>>> store=new LinkedHashMap<>();
......@@ -184,7 +203,10 @@ public class OUModelService
}
}
return store;
deptmap=store;
}
return deptmap;
}
public void loopDept(IBZDepartment dept,Map<String, IBZDepartment> deptset,Map<String, Map<String, Set<String>>> store)
......@@ -201,10 +223,12 @@ public class OUModelService
}
@CacheEvict( value="ibzou-model",allEntries = true)
public void refreshModel()
//@CacheEvict( value="ibzou-model",allEntries = true)
public synchronized void refreshModel()
{
this.deptmap=null;
this.orgmap=null;
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册