flowable自定義流程定義緩存


場景:當大量的流程定義出現的時候,我們勢必會不停的查詢流程定義,然而流程定義之后和版本對應很少發生變化,這個時候,我們可以把這個流程定義緩存起來,以提高系統性能。

這里我采用的是本地緩存

1、定義流程定義緩存對象

 
         
@Component
public class CustomDeploymentCache implements DeploymentCache<ProcessDefinitionCacheEntry> {
// @Autowired
// private CacheManager cacheManager;
public static final Map<String,ProcessDefinitionCacheEntry> caches = new ConcurrentHashMap<>();

@Override
public ProcessDefinitionCacheEntry get(String s) {
return caches.get(s);
}

@Override
public boolean contains(String s) {
boolean flag = false;
if (caches.get(s) != null) {
flag = true;
}
return flag;
}

@Override
public void add(String s, ProcessDefinitionCacheEntry processDefinitionCacheEntry) {
caches.put(s, processDefinitionCacheEntry);
}

@Override
public void remove(String s) {
caches.remove(s);
}

@Override
public void clear() {
caches.clear();
}
}
 

2、配置緩存

//設置緩存
        configure.setProcessDefinitionCache(customDeploymentCache);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM